Skip to content

Commit dbbffa2

Browse files
committedNov 11, 2023
fix(build): remove frontmatter in md file inclusion
closes #3195
1 parent a482611 commit dbbffa2

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed
 

‎__tests__/e2e/markdown-extensions/markdown-extensions.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,9 @@ describe('Markdown File Inclusion', () => {
274274
expect(trim(await p.nth(0).textContent())).toBe('This is a region')
275275
expect(trim(await p.nth(1).textContent())).toBe('This is after region')
276276
})
277+
278+
test('ignore frontmatter if range is not specified', async () => {
279+
const p = page.locator('.vp-doc')
280+
expect(await p.textContent()).not.toContain('title')
281+
})
277282
})

‎__tests__/e2e/markdown-extensions/nested-include.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
title: Nested Include
3+
---
4+
15
<!--@include: ./foo.md-->
26

37
### After Foo

‎src/node/utils/processIncludes.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import path from 'path'
21
import fs from 'fs-extra'
2+
import matter from 'gray-matter'
3+
import path from 'path'
34
import { slash } from '../shared'
45

56
export function processIncludes(
@@ -30,6 +31,8 @@ export function processIncludes(
3031
endLine ? parseInt(endLine, 10) : undefined
3132
)
3233
.join('\n')
34+
} else {
35+
content = matter(content).content
3336
}
3437
includes.push(slash(includePath))
3538
// recursively process includes in the content

0 commit comments

Comments
 (0)
Please sign in to comment.