Naively Programmable Module

    @photogabble/eleventy-plugin-word-stats

    1.0.0 • Public • Published

    Word Stats Plugin for Eleventy

    A lightweight wrapper for making available reading-time to the Eleventy Static Site Generator.

    Install

    npm install --save eleventy-plugin-word-stats
    

    Usage

    In your Eleventy config file (defaults to .eleventy.js):

    const wordStats = require('eleventy-plugin-word-stats');
    
    module.exports = (eleventyConfig) => {
      eleventyConfig.addPlugin(wordStats);
    };

    Now the wordStats filter will be available to use in your templates. For example with Nunjuck it can be used as such:

    <p>{{ content | wordStats }}</p>

    Which will by default output along the lines of:

    <p>1,244 words, 6 min read</p>

    Configuration

    interface Options {
      output?: (stats: object) => string;
      wordBound?: (char: string) => boolean;
      wordsPerMinute?: number;
    }

    Output

    Function that controls the output of the wordStats filter. It's stats argument is provided an object that matches the following interface:

    interface ReadTimeResults {
      text: string;
      time: number;
      words: number;
      minutes: number;
    }

    Install

    npm i @photogabble/eleventy-plugin-word-stats

    DownloadsWeekly Downloads

    11

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    8.05 kB

    Total Files

    7

    Last publish

    Collaborators

    • carbontwelve