metalsmith-commento
A Metalsmith plugin that adds Commento commenting widget and counter scripts.
Installation
$ npm install --save-dev metalsmith-commento
Usage
Place metalsmith-commento
plugin after html files generation, for example after metalsmith-layouts
.
const Metalsmith = ;const commento = ; ... ;
In your templates you need to add <div id="commento"></div>
for commenting widget. For comments counter add link to the post with commento-counter
class name.
Examples:
Page with comments template using handlebars:
Your page markup{{#if comments }}<!-- Comments widget will be rendered in this element -->{{/if}}
Page with counters template using handlebars:
Your page markup {{#if comments }}<!-- Comments counter will be rendered in this element -->{{/if}}
To enable comments for page just add comments: true
to page metadata.
Example:
---title: Hello Worldcomments: true---
To enable comments counter for page just add comments-counter: true
to page metadata.
Example:
---title: Postcomments-counter: true---
Options
For the detailed description of options look at the Commento docs.
cssOverride
Type: String
Default: null
Path to the commento CSS overrides.
autoInit
Type: Boolean
Default: true
Whether commento should be initialized automatically after script load.
idRoot
Type: String
Default: 'commento'
CSS selector string used to find the element in a template to insert comments.
counterSelector
Type: String
Default: '.commento-counter'
CSS selector string used to find links in a template to insert comments counter.
CLI
You can also use the plugin with the Metalsmith CLI by adding a key to your metalsmith.json
file:
License
MIT