add TOC add better blog navigation and a new blog post

This commit is contained in:
Zoe
2024-04-23 18:33:05 -05:00
parent df52d24242
commit 2e75732908
27 changed files with 2530 additions and 10686 deletions

View File

@@ -0,0 +1,16 @@
import { visit } from 'unist-util-visit'
const wpm = 225
export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('content:file:afterParse', (file) => {
if (file._id.endsWith('.md')) {
let wordCount = 0
visit(file.body, (n: any) => n.type === 'text', (node) => {
wordCount += node.value.trim().split(/\s+/).length
})
file.readTime = Math.ceil(wordCount / wpm)
}
})
})