mirror of
https://github.com/cupcakearmy/nicco.io.git
synced 2024-12-21 23:56:26 +00:00
12 lines
359 B
JavaScript
12 lines
359 B
JavaScript
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)
|
|
data.astro.frontmatter.text = textOnPage
|
|
data.astro.frontmatter.readingTime = readingTime
|
|
}
|
|
}
|