From e25e8a2c0d8783aea192553067c350d037c9fa14 Mon Sep 17 00:00:00 2001 From: maomao <1714487678@qq.com> Date: Tue, 9 Apr 2024 21:03:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20frontmatter=20?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 5 +++ .../vite-plugin-markdown-preview@1.1.1.patch | 32 +++++++++++++++++++ pnpm-lock.yaml | 18 +++++++---- 3 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 patches/vite-plugin-markdown-preview@1.1.1.patch diff --git a/package.json b/package.json index 7daef57c..2eafc07d 100644 --- a/package.json +++ b/package.json @@ -45,5 +45,10 @@ "*.{js,jsx,tsx,vue,css,scss,less,md,json}": [ "prettier --write" ] + }, + "pnpm": { + "patchedDependencies": { + "vite-plugin-markdown-preview@1.1.1": "patches/vite-plugin-markdown-preview@1.1.1.patch" + } } } diff --git a/patches/vite-plugin-markdown-preview@1.1.1.patch b/patches/vite-plugin-markdown-preview@1.1.1.patch new file mode 100644 index 00000000..1b3003cd --- /dev/null +++ b/patches/vite-plugin-markdown-preview@1.1.1.patch @@ -0,0 +1,32 @@ +diff --git a/dist/index.js b/dist/index.js +index 5c354f7fc1239f8c5ff92d91ef87afd0eca78bdb..e374d9a8144cafb2a7564480aadc468bbb0111e3 100644 +--- a/dist/index.js ++++ b/dist/index.js +@@ -13,6 +13,7 @@ import { createHash } from "node:crypto"; + import { fromMarkdown } from "mdast-util-from-markdown"; + import { frontmatterFromMarkdown, frontmatterToMarkdown } from "mdast-util-frontmatter"; + import { toMarkdown } from "mdast-util-to-markdown"; ++import { frontmatter } from 'micromark-extension-frontmatter'; + import { visit } from "unist-util-visit"; + function getHash(text) { + return createHash("sha256").update(text).digest("hex").substring(0, 8); +@@ -28,6 +29,7 @@ function praseMeta(meta) { + } + function remarkDemoBlock(id, code, config) { + const tree = fromMarkdown(code, { ++ extensions: [frontmatter(['yaml', 'toml'])], + mdastExtensions: [frontmatterFromMarkdown(["yaml", "toml"])] + }); + const blocks = {}; +diff --git a/package.json b/package.json +index 31fcc5521e2e41ad0faf49359e173eec3ecb62ee..d123b492b36675a1c83bb277805c471878bcea43 100644 +--- a/package.json ++++ b/package.json +@@ -45,6 +45,7 @@ + "mdast-util-from-markdown": "^1.2.0", + "mdast-util-frontmatter": "^1.0.0", + "mdast-util-to-markdown": "^1.5.0", ++ "micromark-extension-frontmatter": "^1.1.1", + "unist-util-visit": "^4.1.1" + }, + "devDependencies": { \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 034cfd04..3360b544 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,5 +1,14 @@ lockfileVersion: '6.0' +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +patchedDependencies: + vite-plugin-markdown-preview@1.1.1: + hash: snjgw2bn6xfqmbtsng4ppakymi + path: patches/vite-plugin-markdown-preview@1.1.1.patch + devDependencies: '@femm/prettier': specifier: ^1.1.0 @@ -45,7 +54,7 @@ devDependencies: version: 3.4.1 vite-plugin-markdown-preview: specifier: ^1.1.1 - version: 1.1.1 + version: 1.1.1(patch_hash=snjgw2bn6xfqmbtsng4ppakymi) vitepress: specifier: ^1.0.1 version: 1.0.1(@algolia/client-search@4.20.0)(@types/node@18.18.6)(postcss@8.4.33)(sass@1.69.4)(search-insights@2.9.0) @@ -2421,7 +2430,7 @@ packages: sade: 1.8.1 dev: true - /vite-plugin-markdown-preview@1.1.1: + /vite-plugin-markdown-preview@1.1.1(patch_hash=snjgw2bn6xfqmbtsng4ppakymi): resolution: {integrity: sha512-IEGw1il2hNvvRbLQBOFNTM9mfOVxsez2fQqz0rwdw7lWsLvvkzraONsp3Fuzb33VNcH5zdKxEKLebVSVbBZiTQ==} engines: {node: ^14.18.0 || >=16.0.0} dependencies: @@ -2433,6 +2442,7 @@ packages: transitivePeerDependencies: - supports-color dev: true + patched: true /vite@5.2.6(@types/node@18.18.6)(sass@1.69.4): resolution: {integrity: sha512-FPtnxFlSIKYjZ2eosBQamz4CbyrTizbZ3hnGJlh/wMtCrlp1Hah6AzBLjGI5I2urTfNnpovpHdrL6YRuBOPnCA==} @@ -2596,7 +2606,3 @@ packages: /zwitch@2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} dev: true - -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false