Skip to content
Filter for 11ty to show the number of downloads of a npm package
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
coverage
src
test
.gitignore
.nycrc
DCO.txt
LICENSE
README.md
index.js
package-lock.json
package.json

README.md

eleventy-filter-npm-package-downloads

CircleCI status Known Vulnerabilities codecov Greenkeeper badge Maintainability

Filter for 11ty to show the number of downloads of a npm package. Based on the work of @alex-page!

Installation

That's easy!

npm install eleventy-filter-npm-package-downloads

Usage

Add it to your .eleventy.js like so:

const npmPackageDownloads = require('eleventy-filter-npm-package-downloads');

module.exports = function (eleventyConfig) {
  eleventyConfig.addNunjucksAsyncFilter('packageDownloads', async (packageName, callback) => {
    await npmPackageDownloads(packageName, callback);
  });

  return {
    templateFormats: [
      'html',
      'md',
      'njk'
    ]
  };
};

Now you can use it in your layout templates:

You've got {{ '@11ty/eleventy' | packageDownloads }} downloads this week!

License

MIT. See LICENSE

You can’t perform that action at this time.