https://github.com/mattjennings/remark-reading-time
Adds estimated reading time to your markdown files
https://github.com/mattjennings/remark-reading-time
Last synced: about 2 months ago
JSON representation
Adds estimated reading time to your markdown files
- Host: GitHub
- URL: https://github.com/mattjennings/remark-reading-time
- Owner: mattjennings
- Created: 2021-07-09T19:20:26.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-10-06T16:28:23.000Z (over 1 year ago)
- Last Synced: 2025-04-08T19:31:49.610Z (about 2 months ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 24
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# remark-reading-time
Adds estimated reading time to your markdown files using [reading-time](https://www.npmjs.com/package/reading-time).
## Usage
```js
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:```js
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:
```js
import { compile } from "@mdx-js/mdx";
import remarkReadingTime 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
],
},
});
```