blog/src/plugins/remark-reading-time.mjs
radishzzz 4ff44f9ac4 style: add image to figure plugin
- Improve styles for images, blockquotes, tables and more
- Fix unexpected line breaks
2025-04-16 06:25:04 +01:00

13 lines
356 B
JavaScript

import { toString } from 'mdast-util-to-string'
import getReadingTime from 'reading-time'
export function remarkReadingTime() {
return (tree, { data }) => {
const textOnPage = toString(tree)
const readingTime = getReadingTime(textOnPage)
data.astro.frontmatter.minutes = Math.max(
1,
Math.round(readingTime.minutes),
)
}
}