Only activate partytown if necessary

This commit is contained in:
prototypa
2022-11-24 14:28:24 -05:00
parent 15ccb6da1e
commit ae7a951e87
3 changed files with 10 additions and 9 deletions

11
src/utils/frontmatter.mjs Normal file
View File

@ -0,0 +1,11 @@
import getReadingTime from 'reading-time';
import { toString } from 'mdast-util-to-string';
export function remarkReadingTime() {
return function (tree, { data }) {
const text = toString(tree);
const readingTime = Math.ceil(getReadingTime(text).minutes);
data.astro.frontmatter.readingTime = readingTime;
};
}