mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-17 03:56:19 +02:00
13 lines
356 B
JavaScript
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),
|
|
)
|
|
}
|
|
}
|