We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8c45261 commit 9201a29Copy full SHA for 9201a29
src/lib/remark.mjs
@@ -0,0 +1,12 @@
1
+import getReadingTime from 'reading-time';
2
+import { toString } from 'mdast-util-to-string';
3
+
4
+export function remarkReadingTime() {
5
+ return function (tree, { data }) {
6
+ const textOnPage = toString(tree);
7
+ const readingTime = getReadingTime(textOnPage);
8
+ // readingTime.text will give us minutes read as a friendly string,
9
+ // i.e. "3 min read"
10
+ data.astro.frontmatter.minutesRead = readingTime.text;
11
+ };
12
+}
0 commit comments