Skip to content

Commit

Permalink
fix(build): remove frontmatter in md file inclusion
Browse files Browse the repository at this point in the history
closes #3195
  • Loading branch information
brc-dd committed Nov 11, 2023
1 parent a482611 commit dbbffa2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions __tests__/e2e/markdown-extensions/markdown-extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,9 @@ describe('Markdown File Inclusion', () => {
expect(trim(await p.nth(0).textContent())).toBe('This is a region')
expect(trim(await p.nth(1).textContent())).toBe('This is after region')
})

test('ignore frontmatter if range is not specified', async () => {
const p = page.locator('.vp-doc')
expect(await p.textContent()).not.toContain('title')
})
})
4 changes: 4 additions & 0 deletions __tests__/e2e/markdown-extensions/nested-include.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: Nested Include
---

<!--@include: ./foo.md-->

### After Foo
Expand Down
5 changes: 4 additions & 1 deletion src/node/utils/processIncludes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path'
import fs from 'fs-extra'
import matter from 'gray-matter'
import path from 'path'
import { slash } from '../shared'

export function processIncludes(
Expand Down Expand Up @@ -30,6 +31,8 @@ export function processIncludes(
endLine ? parseInt(endLine, 10) : undefined
)
.join('\n')
} else {
content = matter(content).content
}
includes.push(slash(includePath))
// recursively process includes in the content
Expand Down

0 comments on commit dbbffa2

Please sign in to comment.