Skip to content

Commit da203c7

Browse files
committed
fix: 修复 frontmatter 解析错误
1 parent 47dee25 commit da203c7

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

packages/vite-plugin-markdown-preview/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"mdast-util-from-markdown": "^1.2.0",
5454
"mdast-util-frontmatter": "^1.0.0",
5555
"mdast-util-to-markdown": "^1.5.0",
56+
"micromark-extension-frontmatter": "^1.1.1",
5657
"unist-util-visit": "^4.1.1"
5758
},
5859
"devDependencies": {

packages/vite-plugin-markdown-preview/src/remark.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Code, Parent } from 'mdast'
44
import { fromMarkdown } from 'mdast-util-from-markdown'
55
import { frontmatterFromMarkdown, frontmatterToMarkdown } from 'mdast-util-frontmatter'
66
import { toMarkdown } from 'mdast-util-to-markdown'
7+
import { frontmatter } from 'micromark-extension-frontmatter'
78
import { type Node, visit } from 'unist-util-visit'
89

910
import { MarkdownPreviewConfig } from '.'
@@ -25,6 +26,7 @@ function praseMeta(meta?: string | null) {
2526
}
2627
export function remarkDemoBlock(id: string, code: string, config: MarkdownPreviewConfig) {
2728
const tree = fromMarkdown(code, {
29+
extensions: [frontmatter(['yaml', 'toml'])],
2830
mdastExtensions: [frontmatterFromMarkdown(['yaml', 'toml'])],
2931
})
3032

pnpm-lock.yaml

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)