Giter VIP home page Giter VIP logo

5t3ph / eleventy-plugin-emoji-readtime Goto Github PK

View Code? Open in Web Editor NEW
16.0 2.0 3.0 42 KB

Eleventy (11ty) plugin that provides a configurable filter to display an estimated read time for Eleventy content, optionally with an emoji visual indicator.

Home Page: https://www.npmjs.com/package/@11tyrocks/eleventy-plugin-emoji-readtime

JavaScript 71.79% HTML 28.21%
11ty 11ty-plugin eleventy-plugin readtime

eleventy-plugin-emoji-readtime's Introduction

Eleventy Plugin: Emoji Read Time

Display an estimated read time for Eleventy content, optionally with an emoji visual indicator.

To Use

This plugin provides a filter that can be applied by passing in the Eleventy-supplied content variable, which work best from the layout used by the content. A simple string is returned, so the text formatting is up to you.

First, install the plugin in your project:

npm install @11tyrocks/eleventy-plugin-emoji-readtime

Then, include it in your .eleventy.js config file:

const emojiReadTime = require("@11tyrocks/eleventy-plugin-emoji-readtime");

module.exports = (eleventyConfig) => {
  eleventyConfig.addPlugin(emojiReadTime);
};

*Review config options and examples below for how to modify the output

Finally, add it as a filter to content wherever you'd like it to display:

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

Example output with defaults:

๐Ÿฟ 7 min. read

Config Options

Option Type Default
wpm number 275
showEmoji boolean true
emoji string ๐Ÿฟ
label string min. read
bucketSize number 5

Config Examples

Change the emoji in use, the words-per-minute (wpm), the label, and the bucketSize, where bucketSize is what minute is divided by to determine how many emoji to show:

eleventyConfig.addPlugin(emojiReadTime, {
  emoji: "๐Ÿ“•",
  label: "mins",
  wpm: 300,
  bucketSize: 3,
});

Which would output:

๐Ÿ“•๐Ÿ“• 7 mins

Remove emoji from being displayed

Or, remove the emoji and only display the number of minutes and a label:

eleventyConfig.addPlugin(emojiReadTime, { showEmoji: false });

Credits

eleventy-plugin-emoji-readtime's People

Contributors

5t3ph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.