Skip to content

apostrophecms/apostrophe-link-widgets

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

ApostropheCMS link widgets

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •