apostrophe-link-widgets

1.2.1 • Public • Published

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 = require('apostrophe-link-widgets/lib/schema.js');

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.

Package Sidebar

Install

npm i apostrophe-link-widgets

Weekly Downloads

27

Version

1.2.1

License

MIT

Unpacked Size

6.34 kB

Total Files

8

Last publish

Collaborators

  • haroun
  • bodonkey
  • etlaurent
  • alexgilbert
  • stuartromanek
  • boutell
  • valjed
  • romanek
  • austinstarin
  • arti5m
  • bgantick
  • alexbea