apostrophe-link-widgets
A link widget for ApostropheCMS.
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
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:
{{ 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.
const linkSchema = ;
In a navigation widget schema
... 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, pass a single link instance in as the argument.