/nera-plugin-tags

A plugin for static side generator nera to create a tag cloud, a tag link list and tag overview pages out of tags of page

Primary LanguageJavaScript

Tags - Nera plugin

This is a plugin for the static side generator Nera to generate a tag cloud, tag links and tag overview pages out of tags of a page.
You can setup a couple of things, but in general everything which is required are some comma separated tags in your Markdown meta section.

Usage

To install this plugin, just copy or clone all of this plugins code into the src/plugins folder of your Nera project.

In addition you could setup a few things in the src/plugins/tags/config/tags.yaml.

# all optional, the values given here are the defaults
meta_property_name: tags
tag_overview_path: '/tags'
tag_separator: ','
tag_overview_layout: pages/default.pug
tag_overview_meta:
  # All of the properties you add here will be added to the meta section of the tag overview page
  keywords: some, special, keywords
  description: A special description

# examples
tag_overview_default_image: /img/banner/banner.jpg
tag_overview_website_image: /img/banner/website-banner.jpg

As you see all properties are optional. The values showing here are the defaults, at least for the first four properties.

If you would like to use more configurations properties, you can just add them to the src/plugins/tags/config/tags.yaml. You can later use them within your templates by calling e.g. app.tagsConfig.tag_overview_whatever_variable.

Tag links

This is just an array of links to the tag overview pages. These can be use e.g. below the main headline of your post.

To render the tag links you just need to iterate over the meta.tagLinks property like this:

if meta.tagLinks.length > 0
    each link in meta.tagLinks
        a(href=link.href) #{ link.name }

Of course you can use a more advanced or suitable markup, if you need

Tag cloud

This is very similar to the tag links element, but more for global usage. It includes all tags every used on any of your posts.

Since it should be available every where you need to iterate over the app.tagCloud property like this:

if app.tagCloud.length > 0
    each tag in app.tagCloud
        a(href=tag.href) #{ tag.name }

Of course you can use a more advanced or suitable markup, as you like

Tag overview pages

All the links available in the tag links or tag cloud would worth nothing, if there wouldn't be a tag overview page.

These pages are generated by this plugin automatically and you can customize a few things like:
tag_overview_layout
The default for this is the /views/page/default.pug layout. Of course you can create your own one and just specify it in the config.

tag_overview_path
The default path for the tag overview pages is /tags. But you could specify another one in the config as well.

tag_overview_meta
This property is merged to the meta section of the tag overview pages. So whatever you add as a property to it, it will be available in your templates for further usage.

In addition to the meta properties you can add on your own, the tag overview page has the following meta properties by default:

  • title - the tag
  • createdAt
  • href
  • dirname
  • tag
  • taggedPages - array of all pages which are tagged with the current tag, sorted by createdAt