npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

metalsmith-disqus

v1.2.5

Published

Disqus comments plugin for Metalsmith.

Downloads

7

Readme

metalsmith-disqus

npm version npm

A Metalsmith plugin that adds Disqus commenting widget and counter scripts. For more information you can read article.

Installation

$ npm install --save-dev metalsmith-disqus

Usage

Place metalsmith-disqus plugin after html files generation, for example after metalsmith-layouts.

const Metalsmith = require('metalsmith');
const disqus     = require('metalsmith-disqus');

Metalsmith(__dirname)
  ...
  .use(disqus({
    siteurl: 'my-site.com',
    shortname: 'my-site'
  }));

In your templates you need to add <div id="disqus_thread"></div> for commenting widget. For comments counter add element with class name disqus-comment-count and data attribute data-disqus-key with renedered key to generate id.

Examples:

Page with comments template using handlebars:

<p>Your page markup<p>
{{#if comments }}
<!-- Comments widget will be rendered in this element -->
<div id="disqus_thread"></div>
{{/if}}

Page with counters template using handlebars:

<p>Your page markup<p>

{{#if comments }}
<!-- Comments counter will be rendered in this element -->
<span class="disqus-comment-count" data-disqus-key="{{title}}"></span>
{{/if}}

To enable comments for page just add comments: true to page metadata. Example:

---
title: Hello World
comments: true
---

To enable comments counter for page just add comments-counter: true to page metadata. Example:

---
title: Post
comments-counter: true
---

To add Disqus DNS prefetch for entry page, for example homepage just add disqus-dns-prefetch: true to page metadata. It will speed up disqus scripts loading. Example:

---
title: My home page
disqus-dns-prefetch: true
---

To add Disqus scripts prefetch for page just add disqus-prefetch-widget: true (for comments widget script) or disqus-prefetch-counter: true (for counter script) to page metadata. It will speed up disqus scripts loading. Example:

---
title: My home page
disqus-prefetch-widget: true
disqus-prefetch-counter: true
---

Counter class name selector can be configured with options.

Options

siteurl - Required

Type: String

Default: ''

Your site url, used to generate page url in Disqus configuration.

shortname - Required

Type: String

Default: ''

Your site short name configured in Disqus, used to generate page url in Disqus configuration.

path

Type: String

Default: 'path'

Propery key in file metadata to get page path, used to generate page url in Disqus configuration. By default uses path property that metalsmith-permalinks plugins adds.

title

Type: String

Default: 'title'

Propery key in file metadata to get page title, used as page title in Disqus configuration.

identifier

Type: String

Default: 'title'

Propery key in file metadata to generate page identifier, used as page identifier in Disqus configuration.

counterSelector

Type: String

Default: '.disqus-comment-count'

CSS selector string to find elements in page template inside whitch insetr comments counter.

CLI

You can also use the plugin with the Metalsmith CLI by adding a key to your metalsmith.json file:

{
  "plugins": {
    "metalsmith-disqus": {
      "siteurl": "my-site.com",
      "shortname": "my-site"
    }
  }
}

License

MIT