remark-reading-time
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

remark-reading-time

Adds estimated reading time to your markdown files using reading-time.

Usage

import readingTime from "remark-reading-time";

remark()
  .use(readingTime)
  .process(markdown, function (err, file) {
    console.log("Reading time is " + file.data.readingTime.text);
  });

By default, it will add the data to readingTime in your data. This can be changed:

import readingTime from "remark-reading-time";

remark()
  .use(readingTime, { attribute: "myKeyName" })
  .process(markdown, function (err, file) {
    console.log("Reading time is " + file.data.myKeyName.text);
  });

MDX

You can also export the data to MDX files:

import { compile } from "@mdx-js/mdx";
import readingTime from "remark-reading-time";
import readingMdxTime from "remark-reading-time/mdx";

const code = await compile(file, {
  compileOptions: {
    remarkPlugins: [
      remarkReadingTime,
      readingMdxTime, // register the mdx after the remarkReadingTime plugin
    ],
  },
});

Readme

Keywords

none

Package Sidebar

Install

npm i remark-reading-time

Weekly Downloads

76,445

Version

2.0.1

License

ISC

Unpacked Size

13.5 kB

Total Files

7

Last publish

Collaborators

  • mattjennings