mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-04 04:25:28 +00:00
feat: add Journal page
This commit is contained in:
13
src/utils/remark-reading-time.ts
Normal file
13
src/utils/remark-reading-time.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
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.text;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user