dependabot/npm_and_yarn/tailwindcss/vite-4.1.17
dependabot/npm_and_yarn/eslint-9.39.1
dependabot/npm_and_yarn/eslint-plugin-astro-1.5.0
dependabot/npm_and_yarn/eslint/js-9.39.1
dependabot/npm_and_yarn/katex-0.16.25
dependabot/npm_and_yarn/sharp-0.34.5
dependabot/npm_and_yarn/tailwindcss/vite-4.1.17
dependabot/npm_and_yarn/tsx-4.20.6
dependabot/npm_and_yarn/typescript-eslint-8.46.4
dependabot/npm_and_yarn/typescript-eslint/eslint-plugin-8.36.0
dependabot/npm_and_yarn/typescript-eslint/parser-8.46.4
main
| 1 | import { toString } from 'mdast-util-to-string' |
| 2 | import getReadingTime from 'reading-time' |
| 3 | |
| 4 | /** |
| 5 | * Remark plugin to calculate and add reading time information to markdown frontmatter |
| 6 | */ |
| 7 | export default function remarkReadingTime() { |
| 8 | return function (tree, file) { |
| 9 | const textOnPage = toString(tree) |
| 10 | const readingTime = getReadingTime(textOnPage) |
| 11 | |
| 12 | const minutes = Math.max(1, Math.round(readingTime.minutes)) |
| 13 | file.data.astro.frontmatter.minutesRead = `${minutes}min` |
| 14 | file.data.astro.frontmatter.readingTime = { |
| 15 | text: `${minutes}min`, |
| 16 | minutes: minutes, |
| 17 | time: readingTime.time, |
| 18 | words: readingTime.words |
| 19 | } |
| 20 | } |
| 21 | } |