Revert "docs: error when frontmatter does not exist" (#11807)

Revert "docs: error when frontmatter does not exist (#10561)"

This reverts commit c88c6cdb8f.
This commit is contained in:
iamkun 2023-03-03 23:42:53 +08:00 committed by GitHub
parent 19b2f76394
commit 829c3dfe60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,9 +48,9 @@ export function MarkdownTransform(): Plugin {
}
const combineScriptSetup = (codes: string[]) =>
`<script setup>
`\n<script setup>
${codes.join('\n')}
</script>\n
</script>
`
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 =