From 829c3dfe6049306a11f33622aff6b6df6549cd75 Mon Sep 17 00:00:00 2001 From: iamkun Date: Fri, 3 Mar 2023 23:42:53 +0800 Subject: [PATCH] Revert "docs: error when frontmatter does not exist" (#11807) Revert "docs: error when frontmatter does not exist (#10561)" This reverts commit c88c6cdb8f5a20e4d395f9430f0ee72601443fbf. --- docs/.vitepress/plugins/markdown-transform.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/docs/.vitepress/plugins/markdown-transform.ts b/docs/.vitepress/plugins/markdown-transform.ts index f7ba7678c9..99a3656ffb 100644 --- a/docs/.vitepress/plugins/markdown-transform.ts +++ b/docs/.vitepress/plugins/markdown-transform.ts @@ -48,9 +48,9 @@ export function MarkdownTransform(): Plugin { } const combineScriptSetup = (codes: string[]) => - `\n + ` const combineMarkdown = ( @@ -58,14 +58,9 @@ const combineMarkdown = ( headers: string[], footers: string[] ) => { - const frontmatterEnds = code.indexOf('---\n\n') - const firstSubheader = code.search(/## \w/) - const sliceIndex = - firstSubheader < 0 - ? frontmatterEnds < 0 - ? 0 - : frontmatterEnds + 5 - : firstSubheader + const frontmatterEnds = code.indexOf('---\n\n') + 4 + const firstSubheader = code.search(/\n## \w/) + const sliceIndex = firstSubheader < 0 ? frontmatterEnds : firstSubheader if (headers.length > 0) code =