mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-03 20:15:27 +00:00
14 lines
382 B
TypeScript
14 lines
382 B
TypeScript
import { toString } from 'mdast-util-to-string';
|
|
import getReadingTime from 'reading-time';
|
|
|
|
import type { Node } from 'unist';
|
|
|
|
export const remarkReadingTime = () => {
|
|
return function (tree: Node, { data }: { data: any }) {
|
|
const textOnPage = toString(tree);
|
|
const readingTime = getReadingTime(textOnPage);
|
|
|
|
data.astro.frontmatter.minutesRead = readingTime.minutes;
|
|
};
|
|
};
|