Skip to content

Commit

Permalink
New Book Review: He Who Fights With Monsters
Browse files Browse the repository at this point in the history
  • Loading branch information
Hopelezz committed Oct 29, 2022
1 parent 4956b84 commit 4141381
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions remark-reading-time.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import getReadingTime from 'reading-time';
import { toString } from 'mdast-util-to-string';

export function remarkReadingTime() {
return function (tree, { data }) {
const textOnPage = toString(tree);
const readingTime = getReadingTime(textOnPage);
// readingTime.text will give us minutes read as a friendly string,
// i.e. "3 min read"
data.astro.frontmatter.minutesRead = readingTime.text;
};
}
Empty file.

0 comments on commit 4141381

Please sign in to comment.