test: add plugins

This commit is contained in:
radishzzz 2025-01-13 23:02:00 +00:00
parent 4341dab741
commit 9e9cdcb206
8 changed files with 257 additions and 4 deletions

View file

@ -0,0 +1,26 @@
import type { Root } from 'mdast'
import { toString } from 'mdast-util-to-string'
interface AstroData {
data: {
astro: {
frontmatter: {
excerpt: string
}
}
}
}
export function remarkExcerpt() {
return (tree: Root, file: AstroData) => {
let excerpt = ''
for (const node of tree.children) {
if (node.type !== 'paragraph') {
continue
}
excerpt = toString(node)
break
}
file.data.astro.frontmatter.excerpt = excerpt
}
}