blob: 93f7b00f6d58e9a9086ab89198e28776197ad310 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
|
import type { RemarkPlugin } from "@astrojs/markdown-remark";
import { toString } from "mdast-util-to-string";
import getReadingTime from "reading-time";
export function remarkReadingTime(): RemarkPlugin {
return function (tree, { data }) {
const textOnPage = toString(tree);
const readingTime = getReadingTime(textOnPage);
data.astro.frontmatter.minutesRead = readingTime.text;
};
}
|