Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apostrophecms/apostrophe-link-widgets
ApostropheCMS link widgets
https://github.com/apostrophecms/apostrophe-link-widgets
apostrophecms nodejs
Last synced: about 2 months ago
JSON representation
ApostropheCMS link widgets
- Host: GitHub
- URL: https://github.com/apostrophecms/apostrophe-link-widgets
- Owner: apostrophecms
- License: mit
- Created: 2017-10-08T21:31:55.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2021-07-15T21:18:16.000Z (over 3 years ago)
- Last Synced: 2024-10-03T10:17:53.569Z (3 months ago)
- Topics: apostrophecms, nodejs
- Language: JavaScript
- Homepage:
- Size: 41 KB
- Stars: 3
- Watchers: 16
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# apostrophe-link-widgets
A link widget for [ApostropheCMS](http://apostrophecms.org/).
`apostrophe-link-widgets` provides a simple way for users to create a link, giving them the option to choose a page or enter a URL manually.
## Installation
```bash
npm install apostrophe-link-widgets --save
```## Use as a widget
You can use `apostrophe-link-widgets` as you would any widget in ApostropheCMS.Here's an example of a singleton:
```nunjucks
{{ apos.singleton(data.page, 'link', 'apostrophe-link') }}
```## Use as a schema
You can also `require` the schema for `apostrophe-link-widgets` so it can be leveraged across other schemas. This is useful when building more than one link-like thing (array of links for navigations) or appending link-like properties to other schemas/widgets.```js
const linkSchema = require('apostrophe-link-widgets/lib/schema.js');
```
In a navigation widget schema```js
...
{
name: 'navPrimaryItems',
help: 'Navigation items for the primary nav',
label: 'Primary Navigation Items',
type: 'array',
titleField: 'linkText',
schema: linkSchema
}
```## Options
`classes`: Takes an array of CSS class names to be applied to the link
## Template helper
When building custom templates using this module, finding the right type of link and getting the URL out based on that type can be very verbose. This module includes a template helper to make this simpler. Use `apos.links.linkPath(data.widget)` to get the correct URL path. If [using the schema independently](#use-as-a-schema), pass a single link instance in as the argument.