Skip to content

Commit 0c4210b

Browse files
Jeff-Tianbrc-dd
andauthored
feat(build): support nested markdown includes (vuejs#2545)
Co-authored-by: Divyansh Singh <[email protected]>
1 parent c6ab139 commit 0c4210b

File tree

8 files changed

+200
-183
lines changed

8 files changed

+200
-183
lines changed

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ cache
66
template
77
temp
88
!CHANGELOG.md
9+
.temp

__tests__/e2e/markdown-extensions/index.md

+5
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,8 @@ export default config
180180
## Markdown At File Inclusion
181181

182182
<!--@include: @/markdown-extensions/bar.md-->
183+
184+
185+
## Markdown Nested File Inclusion
186+
187+
<!--@include: ./nested-include.md-->

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('Table of Contents', () => {
6363
test('render toc', async () => {
6464
const items = page.locator('#table-of-contents + nav ul li')
6565
const count = await items.count()
66-
expect(count).toBe(24)
66+
expect(count).toBe(27)
6767
})
6868
})
6969

@@ -233,4 +233,8 @@ describe('Markdown File Inclusion', () => {
233233
const h1 = page.locator('#markdown-at-file-inclusion + h1')
234234
expect(await h1.getAttribute('id')).toBe('bar')
235235
})
236+
test('render markdown using nested inclusion', async () => {
237+
const h1 = page.locator('#markdown-nested-file-inclusion + h1')
238+
expect(await h1.getAttribute('id')).toBe('foo-1')
239+
})
236240
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<!--@include: ./foo.md-->
2+
3+
### After Foo

docs/guide/markdown.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -696,10 +696,10 @@ You can also [import snippets](#import-code-snippets) in code groups:
696696

697697
## Markdown File Inclusion
698698

699-
You can include a markdown file in another markdown file.
699+
You can include a markdown file in another markdown file, even nested.
700700

701701
::: tip
702-
You can also prefix the markdown path with `@`, it will act as the source root. By default it's the VitePress project root, unless `srcDir` is configured.
702+
You can also prefix the markdown path with `@`, it will act as the source root. By default, it's the VitePress project root, unless `srcDir` is configured.
703703
:::
704704

705705
For example, you can include a relative markdown file using this:

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.0-beta.3",
44
"description": "Vite & Vue powered static site generator",
55
"type": "module",
6-
"packageManager": "[email protected].3",
6+
"packageManager": "[email protected].5",
77
"main": "dist/node/index.js",
88
"types": "types/index.d.ts",
99
"exports": {
@@ -130,14 +130,14 @@
130130
"@types/markdown-it-emoji": "^2.0.2",
131131
"@types/micromatch": "^4.0.2",
132132
"@types/minimist": "^1.2.2",
133-
"@types/node": "^20.3.1",
133+
"@types/node": "^20.3.2",
134134
"@types/prompts": "^2.4.4",
135135
"chokidar": "^3.5.3",
136136
"compression": "^1.7.4",
137137
"conventional-changelog-cli": "^2",
138138
"cross-spawn": "^7.0.3",
139139
"debug": "^4.3.4",
140-
"esbuild": "^0.18.7",
140+
"esbuild": "^0.18.10",
141141
"escape-html": "^1.0.3",
142142
"execa": "^7.1.1",
143143
"fast-glob": "^3.2.12",
@@ -166,7 +166,7 @@
166166
"prompts": "^2.4.2",
167167
"punycode": "^2.3.0",
168168
"rimraf": "^5.0.1",
169-
"rollup": "^3.25.1",
169+
"rollup": "^3.25.3",
170170
"rollup-plugin-dts": "^5.3.0",
171171
"rollup-plugin-esbuild": "^5.0.0",
172172
"semver": "^7.5.3",
@@ -176,7 +176,7 @@
176176
"supports-color": "^9.3.1",
177177
"typescript": "^5.1.3",
178178
"vitest": "^0.32.2",
179-
"vue-tsc": "^1.8.1",
179+
"vue-tsc": "^1.8.2",
180180
"wait-on": "^7.0.1"
181181
},
182182
"simple-git-hooks": {

0 commit comments

Comments
 (0)