0
mirror of https://github.com/valentineus/popov.link.git synced 2025-07-04 08:30:27 +03:00

Added reading time timer

This commit is contained in:
2024-09-06 08:21:27 +00:00
parent 17c3115a06
commit 2f362eaf09
9 changed files with 59 additions and 46 deletions

View File

@ -0,0 +1,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;
};
}