Merge remote-tracking branch 'origin/main' into lejunyang-main

pull/4126/head
Divyansh Singh 1 year ago
commit a224749c96

@ -13,7 +13,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions-ecosystem/action-add-labels@v1 - run: gh issue edit ${{ github.event.issue.number }} --add-label cr-tracked --repo ${{ github.repository }}
with: env:
labels: cr-tracked GITHUB_TOKEN: ${{ secrets.CR_PAT }}
github_token: ${{ secrets.CR_PAT }}

@ -16,6 +16,10 @@ on:
permissions: {} permissions: {}
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true
jobs: jobs:
release: release:
if: ${{ !github.event.pull_request.draft && contains(github.event.pull_request.labels.*.name, 'cr-tracked') && !contains(github.event.pull_request.labels.*.name, 'spam') && !contains(github.event.pull_request.labels.*.name, 'invalid') }} if: ${{ !github.event.pull_request.draft && contains(github.event.pull_request.labels.*.name, 'cr-tracked') && !contains(github.event.pull_request.labels.*.name, 'spam') && !contains(github.event.pull_request.labels.*.name, 'invalid') }}

@ -1,3 +1,15 @@
## [1.3.4](https://github.com/vuejs/vitepress/compare/v1.3.3...v1.3.4) (2024-08-24)
### Bug Fixes
- check if `_importGlobMap` (vite internal) exists before using it ([612d66f](https://github.com/vuejs/vitepress/commit/612d66fbb5162d9905cfb10919ca1761ce8c4680))
## [1.3.3](https://github.com/vuejs/vitepress/compare/v1.3.2...v1.3.3) (2024-08-17)
### Miscellaneous
- bump deps ([a20db24](https://github.com/vuejs/vitepress/commit/a20db247822438ac4e0e76bc4a2b4ee2f5d94940))
## [1.3.2](https://github.com/vuejs/vitepress/compare/v1.3.1...v1.3.2) (2024-08-05) ## [1.3.2](https://github.com/vuejs/vitepress/compare/v1.3.1...v1.3.2) (2024-08-05)
### Bug Fixes ### Bug Fixes

@ -7,14 +7,10 @@ export declare const data: Data
export default defineLoader({ export default defineLoader({
watch: ['./data/*'], watch: ['./data/*'],
async load(files: string[]): Promise<Data> { async load(files: string[]): Promise<Data> {
const foo = fs.readFileSync( const data: Data = []
files.find((f) => f.endsWith('foo.json'))!, for (const file of files.sort().filter((file) => file.endsWith('.json'))) {
'utf-8' data.push(JSON.parse(fs.readFileSync(file, 'utf-8')))
) }
const bar = fs.readFileSync( return data
files.find((f) => f.endsWith('bar.json'))!,
'utf-8'
)
return [JSON.parse(foo), JSON.parse(bar)]
} }
}) })

@ -1,3 +1,6 @@
import fs from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
describe('static data file support in vite 3', () => { describe('static data file support in vite 3', () => {
beforeAll(async () => { beforeAll(async () => {
await goto('/data-loading/data') await goto('/data-loading/data')
@ -7,10 +10,10 @@ describe('static data file support in vite 3', () => {
expect(await page.textContent('pre#basic')).toMatchInlineSnapshot(` expect(await page.textContent('pre#basic')).toMatchInlineSnapshot(`
"[ "[
{ {
"foo": true "a": true
}, },
{ {
"bar": true "b": true
} }
]" ]"
`) `)
@ -39,4 +42,68 @@ describe('static data file support in vite 3', () => {
]" ]"
`) `)
}) })
// TODO: make it `.runIf(!process.env.VITE_TEST_BUILD)` -- it currently works, but is skipped to avoid vite's ecosystem-ci from failing (https://github.com/vitejs/vite/pull/16471#issuecomment-2308437187)
test.skip('hmr works', async () => {
const a = fileURLToPath(new URL('./data/a.json', import.meta.url))
const b = fileURLToPath(new URL('./data/b.json', import.meta.url))
try {
await fs.writeFile(a, JSON.stringify({ a: false }, null, 2) + '\n')
await page.waitForFunction(
() =>
document.querySelector('pre#basic')?.textContent ===
JSON.stringify([{ a: false }, { b: true }], null, 2),
undefined,
{ timeout: 3000 }
)
} finally {
await fs.writeFile(a, JSON.stringify({ a: true }, null, 2) + '\n')
}
let err = true
try {
await fs.unlink(b)
await page.waitForFunction(
() =>
document.querySelector('pre#basic')?.textContent ===
JSON.stringify([{ a: true }], null, 2),
undefined,
{ timeout: 3000 }
)
err = false
} finally {
if (err) {
await fs.writeFile(b, JSON.stringify({ b: true }, null, 2) + '\n')
}
}
try {
await fs.writeFile(b, JSON.stringify({ b: false }, null, 2) + '\n')
await page.waitForFunction(
() =>
document.querySelector('pre#basic')?.textContent ===
JSON.stringify([{ a: true }, { b: false }], null, 2),
undefined,
{ timeout: 3000 }
)
} finally {
await fs.writeFile(b, JSON.stringify({ b: true }, null, 2) + '\n')
}
})
/*
MODIFY a.json with { a: false }
this should trigger a hmr update and the content should be updated to [{ a: false }, { b: true }]
reset a.json
DELETE b.json
this should trigger a hmr update and the content should be updated to [{ a: true }]
reset b.json if failed
CREATE b.json with { b: false }
this should trigger a hmr update and the content should be updated to [{ a: true }, { b: false }]
reset b.json
*/
}) })

@ -1,5 +1,11 @@
import { resolveHeaders } from 'client/theme-default/composables/outline' import { resolveHeaders } from 'client/theme-default/composables/outline'
const element = {
classList: {
contains: () => false
}
} as unknown as HTMLHeadElement
describe('client/theme-default/composables/outline', () => { describe('client/theme-default/composables/outline', () => {
describe('resolveHeader', () => { describe('resolveHeader', () => {
test('levels range', () => { test('levels range', () => {
@ -9,12 +15,14 @@ describe('client/theme-default/composables/outline', () => {
{ {
level: 2, level: 2,
title: 'h2 - 1', title: 'h2 - 1',
link: '#h2-1' link: '#h2-1',
element
}, },
{ {
level: 3, level: 3,
title: 'h3 - 1', title: 'h3 - 1',
link: '#h3-1' link: '#h3-1',
element
} }
], ],
[2, 3] [2, 3]
@ -28,9 +36,12 @@ describe('client/theme-default/composables/outline', () => {
{ {
level: 3, level: 3,
title: 'h3 - 1', title: 'h3 - 1',
link: '#h3-1' link: '#h3-1',
children: [],
element
} }
] ],
element
} }
]) ])
}) })
@ -42,12 +53,14 @@ describe('client/theme-default/composables/outline', () => {
{ {
level: 2, level: 2,
title: 'h2 - 1', title: 'h2 - 1',
link: '#h2-1' link: '#h2-1',
element
}, },
{ {
level: 3, level: 3,
title: 'h3 - 1', title: 'h3 - 1',
link: '#h3-1' link: '#h3-1',
element
} }
], ],
2 2
@ -56,7 +69,9 @@ describe('client/theme-default/composables/outline', () => {
{ {
level: 2, level: 2,
title: 'h2 - 1', title: 'h2 - 1',
link: '#h2-1' link: '#h2-1',
children: [],
element
} }
]) ])
}) })
@ -68,42 +83,50 @@ describe('client/theme-default/composables/outline', () => {
{ {
level: 2, level: 2,
title: 'h2 - 1', title: 'h2 - 1',
link: '#h2-1' link: '#h2-1',
element
}, },
{ {
level: 3, level: 3,
title: 'h3 - 1', title: 'h3 - 1',
link: '#h3-1' link: '#h3-1',
element
}, },
{ {
level: 4, level: 4,
title: 'h4 - 1', title: 'h4 - 1',
link: '#h4-1' link: '#h4-1',
element
}, },
{ {
level: 3, level: 3,
title: 'h3 - 2', title: 'h3 - 2',
link: '#h3-2' link: '#h3-2',
element
}, },
{ {
level: 4, level: 4,
title: 'h4 - 2', title: 'h4 - 2',
link: '#h4-2' link: '#h4-2',
element
}, },
{ {
level: 2, level: 2,
title: 'h2 - 2', title: 'h2 - 2',
link: '#h2-2' link: '#h2-2',
element
}, },
{ {
level: 3, level: 3,
title: 'h3 - 3', title: 'h3 - 3',
link: '#h3-3' link: '#h3-3',
element
}, },
{ {
level: 4, level: 4,
title: 'h4 - 3', title: 'h4 - 3',
link: '#h4-3' link: '#h4-3',
element
} }
], ],
'deep' 'deep'
@ -122,9 +145,12 @@ describe('client/theme-default/composables/outline', () => {
{ {
level: 4, level: 4,
title: 'h4 - 1', title: 'h4 - 1',
link: '#h4-1' link: '#h4-1',
children: [],
element
} }
] ],
element
}, },
{ {
level: 3, level: 3,
@ -134,11 +160,15 @@ describe('client/theme-default/composables/outline', () => {
{ {
level: 4, level: 4,
title: 'h4 - 2', title: 'h4 - 2',
link: '#h4-2' link: '#h4-2',
children: [],
element
} }
] ],
element
} }
] ],
element
}, },
{ {
level: 2, level: 2,
@ -153,11 +183,15 @@ describe('client/theme-default/composables/outline', () => {
{ {
level: 4, level: 4,
title: 'h4 - 3', title: 'h4 - 3',
link: '#h4-3' link: '#h4-3',
children: [],
element
} }
] ],
element
} }
] ],
element
} }
]) ])
}) })

@ -161,6 +161,12 @@ aside: false
The levels of header in the outline to display for the page. It's same as [config.themeConfig.outline.level](./default-theme-config#outline), and it overrides the value set in site-level config. The levels of header in the outline to display for the page. It's same as [config.themeConfig.outline.level](./default-theme-config#outline), and it overrides the value set in site-level config.
```yaml
---
outline: [2, 4]
---
```
### lastUpdated ### lastUpdated
- Type: `boolean | Date` - Type: `boolean | Date`

@ -1,6 +1,6 @@
{ {
"name": "vitepress", "name": "vitepress",
"version": "1.3.2", "version": "1.3.4",
"description": "Vite & Vue powered static site generator", "description": "Vite & Vue powered static site generator",
"keywords": [ "keywords": [
"vite", "vite",
@ -98,22 +98,22 @@
"*": "prettier --write --ignore-unknown" "*": "prettier --write --ignore-unknown"
}, },
"dependencies": { "dependencies": {
"@docsearch/css": "^3.6.0", "@docsearch/css": "^3.6.1",
"@docsearch/js": "^3.6.0", "@docsearch/js": "^3.6.1",
"@shikijs/core": "^1.10.3", "@shikijs/core": "^1.15.2",
"@shikijs/transformers": "^1.10.3", "@shikijs/transformers": "^1.15.2",
"@types/markdown-it": "^14.1.1", "@types/markdown-it": "^14.1.2",
"@vitejs/plugin-vue": "^5.0.5", "@vitejs/plugin-vue": "^5.1.3",
"@vue/devtools-api": "^7.3.5", "@vue/devtools-api": "^7.3.9",
"@vue/shared": "^3.4.31", "@vue/shared": "^3.4.38",
"@vueuse/core": "^10.11.0", "@vueuse/core": "^11.0.3",
"@vueuse/integrations": "^10.11.0", "@vueuse/integrations": "^11.0.3",
"focus-trap": "^7.5.4", "focus-trap": "^7.5.4",
"mark.js": "8.11.1", "mark.js": "8.11.1",
"minisearch": "^7.0.0", "minisearch": "^7.1.0",
"shiki": "^1.10.3", "shiki": "^1.15.2",
"vite": "^5.3.3", "vite": "^5.4.2",
"vue": "^3.4.31" "vue": "^3.4.38"
}, },
"devDependencies": { "devDependencies": {
"@clack/prompts": "^0.7.0", "@clack/prompts": "^0.7.0",
@ -124,7 +124,7 @@
"@mdit-vue/plugin-title": "^2.1.3", "@mdit-vue/plugin-title": "^2.1.3",
"@mdit-vue/plugin-toc": "^2.1.3", "@mdit-vue/plugin-toc": "^2.1.3",
"@mdit-vue/shared": "^2.1.3", "@mdit-vue/shared": "^2.1.3",
"@polka/compression": "^1.0.0-next.25", "@polka/compression": "^1.0.0-next.26",
"@rollup/plugin-alias": "^5.1.0", "@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-commonjs": "^26.0.1", "@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-json": "^6.1.0", "@rollup/plugin-json": "^6.1.0",
@ -140,55 +140,55 @@
"@types/markdown-it-emoji": "^3.0.1", "@types/markdown-it-emoji": "^3.0.1",
"@types/micromatch": "^4.0.9", "@types/micromatch": "^4.0.9",
"@types/minimist": "^1.2.5", "@types/minimist": "^1.2.5",
"@types/node": "^20.14.10", "@types/node": "^22.5.1",
"@types/postcss-prefix-selector": "^1.16.3", "@types/postcss-prefix-selector": "^1.16.3",
"@types/prompts": "^2.4.9", "@types/prompts": "^2.4.9",
"chokidar": "^3.6.0", "chokidar": "^3.6.0",
"conventional-changelog-cli": "^5.0.0", "conventional-changelog-cli": "^5.0.0",
"cross-spawn": "^7.0.3", "cross-spawn": "^7.0.3",
"debug": "^4.3.5", "debug": "^4.3.6",
"esbuild": "^0.23.0", "esbuild": "^0.23.1",
"execa": "^9.3.0", "execa": "^9.3.1",
"fast-glob": "^3.3.2", "fast-glob": "^3.3.2",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
"get-port": "^7.1.0", "get-port": "^7.1.0",
"gray-matter": "^4.0.3", "gray-matter": "^4.0.3",
"lint-staged": "^15.2.7", "lint-staged": "^15.2.9",
"lodash.template": "^4.5.0", "lodash.template": "^4.5.0",
"lru-cache": "^11.0.0", "lru-cache": "^11.0.0",
"markdown-it": "^14.1.0", "markdown-it": "^14.1.0",
"markdown-it-anchor": "^9.0.1", "markdown-it-anchor": "^9.1.0",
"markdown-it-attrs": "^4.1.6", "markdown-it-attrs": "^4.2.0",
"markdown-it-container": "^4.0.0", "markdown-it-container": "^4.0.0",
"markdown-it-emoji": "^3.0.0", "markdown-it-emoji": "^3.0.0",
"markdown-it-mathjax3": "^4.3.2", "markdown-it-mathjax3": "^4.3.2",
"micromatch": "^4.0.7", "micromatch": "^4.0.8",
"minimist": "^1.2.8", "minimist": "^1.2.8",
"nanoid": "^5.0.7", "nanoid": "^5.0.7",
"ora": "^8.0.1", "ora": "^8.1.0",
"p-map": "^7.0.2", "p-map": "^7.0.2",
"path-to-regexp": "^6.2.2", "path-to-regexp": "^6.2.2",
"picocolors": "^1.0.1", "picocolors": "^1.0.1",
"pkg-dir": "^8.0.0", "pkg-dir": "^8.0.0",
"playwright-chromium": "^1.45.1", "playwright-chromium": "^1.46.1",
"polka": "^1.0.0-next.25", "polka": "^1.0.0-next.25",
"postcss-prefix-selector": "^1.16.1", "postcss-prefix-selector": "^1.16.1",
"prettier": "^3.3.3", "prettier": "^3.3.3",
"prompts": "^2.4.2", "prompts": "^2.4.2",
"punycode": "^2.3.1", "punycode": "^2.3.1",
"rimraf": "^6.0.1", "rimraf": "^6.0.1",
"rollup": "^4.18.1", "rollup": "^4.21.2",
"rollup-plugin-dts": "^6.1.1", "rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^6.1.1", "rollup-plugin-esbuild": "^6.1.1",
"semver": "^7.6.2", "semver": "^7.6.3",
"simple-git-hooks": "^2.11.1", "simple-git-hooks": "^2.11.1",
"sirv": "^2.0.4", "sirv": "^2.0.4",
"sitemap": "^8.0.0", "sitemap": "^8.0.0",
"supports-color": "^9.4.0", "supports-color": "^9.4.0",
"typescript": "^5.5.3", "typescript": "^5.5.4",
"vitest": "^2.0.2", "vitest": "^2.0.5",
"vue-tsc": "^2.0.29", "vue-tsc": "^2.1.4",
"wait-on": "^7.2.0" "wait-on": "^8.0.0"
}, },
"peerDependencies": { "peerDependencies": {
"markdown-it-mathjax3": "^4", "markdown-it-mathjax3": "^4",
@ -202,7 +202,7 @@
"optional": true "optional": true
} }
}, },
"packageManager": "pnpm@9.5.0", "packageManager": "pnpm@9.9.0",
"pnpm": { "pnpm": {
"peerDependencyRules": { "peerDependencyRules": {
"ignoreMissing": [ "ignoreMissing": [

File diff suppressed because it is too large Load Diff

@ -1,4 +1,4 @@
import { defineComponent, h } from 'vue' import { defineComponent, h, watch } from 'vue'
import { useData, useRoute } from 'vitepress' import { useData, useRoute } from 'vitepress'
import { contentUpdatedCallbacks } from '../utils' import { contentUpdatedCallbacks } from '../utils'
@ -11,7 +11,8 @@ export const Content = defineComponent({
}, },
setup(props) { setup(props) {
const route = useRoute() const route = useRoute()
const { site } = useData() const { frontmatter, site } = useData()
watch(frontmatter, runCbs, { deep: true, flush: 'post' })
return () => return () =>
h( h(
props.as, props.as,

@ -13,7 +13,7 @@ export type MenuItem = Omit<Header, 'slug' | 'children'> & {
children?: MenuItem[] children?: MenuItem[]
} }
export function resolveTitle(theme: DefaultTheme.Config) { export function resolveTitle(theme: DefaultTheme.Config): string {
return ( return (
(typeof theme.outline === 'object' && (typeof theme.outline === 'object' &&
!Array.isArray(theme.outline) && !Array.isArray(theme.outline) &&
@ -23,7 +23,7 @@ export function resolveTitle(theme: DefaultTheme.Config) {
) )
} }
export function getHeaders(range: DefaultTheme.Config['outline']) { export function getHeaders(range: DefaultTheme.Config['outline']): MenuItem[] {
const headers = [ const headers = [
...document.querySelectorAll('.VPDoc :where(h1,h2,h3,h4,h5,h6)') ...document.querySelectorAll('.VPDoc :where(h1,h2,h3,h4,h5,h6)')
] ]
@ -80,38 +80,13 @@ export function resolveHeaders(
? [2, 6] ? [2, 6]
: levelsRange : levelsRange
headers = headers.filter((h) => h.level >= high && h.level <= low) return buildTree(headers, high, low)
// clear previous caches
resolvedHeaders.length = 0
// update global header list for active link rendering
for (const { element, link } of headers) {
resolvedHeaders.push({ element, link })
}
const ret: MenuItem[] = []
outer: for (let i = 0; i < headers.length; i++) {
const cur = headers[i]
if (i === 0) {
ret.push(cur)
} else {
for (let j = i - 1; j >= 0; j--) {
const prev = headers[j]
if (prev.level < cur.level) {
;(prev.children || (prev.children = [])).push(cur)
continue outer
}
}
ret.push(cur)
}
}
return ret
} }
export function useActiveAnchor( export function useActiveAnchor(
container: Ref<HTMLElement>, container: Ref<HTMLElement>,
marker: Ref<HTMLElement> marker: Ref<HTMLElement>
) { ): void {
const { isAsideEnabled } = useAside() const { isAsideEnabled } = useAside()
const onScroll = throttleAndDebounce(setActiveLink, 100) const onScroll = throttleAndDebounce(setActiveLink, 100)
@ -221,3 +196,38 @@ function getAbsoluteTop(element: HTMLElement): number {
} }
return offsetTop return offsetTop
} }
function buildTree(data: MenuItem[], min: number, max: number): MenuItem[] {
resolvedHeaders.length = 0
const result: MenuItem[] = []
const stack: (MenuItem | { level: number; shouldIgnore: true })[] = []
data.forEach((item) => {
const node = { ...item, children: [] }
let parent = stack[stack.length - 1]
while (parent && parent.level >= node.level) {
stack.pop()
parent = stack[stack.length - 1]
}
if (
node.element.classList.contains('ignore-header') ||
(parent && 'shouldIgnore' in parent)
) {
stack.push({ level: node.level, shouldIgnore: true })
return
}
if (node.level > max || node.level < min) return
resolvedHeaders.push({ element: node.element, link: node.link })
if (parent) parent.children!.push(node)
else result.push(node)
stack.push(node)
})
return result
}

@ -5,7 +5,7 @@
"outDir": "../../dist/client", "outDir": "../../dist/client",
"declaration": true, "declaration": true,
"declarationDir": "../../dist/client-types", "declarationDir": "../../dist/client-types",
"types": ["vite/client"], "types": ["vite/client", "@types/node"],
"paths": { "paths": {
"vitepress": ["index.ts"], "vitepress": ["index.ts"],
"vitepress/theme": ["../../theme.d.ts"] "vitepress/theme": ["../../theme.d.ts"]

@ -48,7 +48,7 @@ export const containerPlugin = (
render: (tokens: Token[], idx: number) => render: (tokens: Token[], idx: number) =>
tokens[idx].nesting === 1 ? `<div class="vp-raw">\n` : `</div>\n` tokens[idx].nesting === 1 ? `<div class="vp-raw">\n` : `</div>\n`
}) })
.use(...createCodeGroup(options)) .use(...createCodeGroup(options, md))
} }
type ContainerArgs = [typeof container, string, { render: RenderRule }] type ContainerArgs = [typeof container, string, { render: RenderRule }]
@ -79,7 +79,7 @@ function createContainer(
] ]
} }
function createCodeGroup(options: Options): ContainerArgs { function createCodeGroup(options: Options, md: MarkdownIt): ContainerArgs {
return [ return [
container, container,
'code-group', 'code-group',
@ -111,7 +111,7 @@ function createCodeGroup(options: Options): ContainerArgs {
if (title) { if (title) {
const id = nanoid(7) const id = nanoid(7)
tabs += `<input type="radio" name="group-${name}" id="tab-${id}" ${checked}><label for="tab-${id}">${title}</label>` tabs += `<input type="radio" name="group-${name}" id="tab-${id}" ${checked}><label data-title="${md.utils.escapeHtml(title)}" for="tab-${id}">${title}</label>`
if (checked && !isHtml) tokens[i].info += ' active' if (checked && !isHtml) tokens[i].info += ' active'
checked = '' checked = ''

@ -57,21 +57,33 @@ export async function createMarkdownToVueRenderFn(
base, base,
siteConfig?.logger siteConfig?.logger
) )
pages = pages.map((p) => slash(p.replace(/\.md$/, ''))) pages = pages.map((p) => slash(p.replace(/\.md$/, '')))
const dynamicRoutes = new Map(
siteConfig?.dynamicRoutes?.routes.map((r) => [
r.fullPath,
path.join(srcDir, r.route)
]) || []
)
const rewrites = new Map(
Object.entries(siteConfig?.rewrites.map || {}).map(([key, value]) => [
path.join(srcDir, key),
path.join(srcDir, value!)
]) || []
)
return async ( return async (
src: string, src: string,
file: string, file: string,
publicDir: string publicDir: string
): Promise<MarkdownCompileResult> => { ): Promise<MarkdownCompileResult> => {
const fileOrig = file const fileOrig = dynamicRoutes.get(file) || file
const alias = file = rewrites.get(file) || file
siteConfig?.rewrites.map[file] || // virtual dynamic path file
siteConfig?.rewrites.map[file.slice(srcDir.length + 1)]
file = alias ? path.join(srcDir, alias) : file
const relativePath = slash(path.relative(srcDir, file)) const relativePath = slash(path.relative(srcDir, file))
const cacheKey = JSON.stringify({ src, file: fileOrig })
const cacheKey = JSON.stringify({ src, file: relativePath })
if (isBuild || options.cache !== false) { if (isBuild || options.cache !== false) {
const cached = cache.get(cacheKey) const cached = cache.get(cacheKey)
if (cached) { if (cached) {

@ -402,8 +402,9 @@ export async function createVitePressPlugin(
config.publicDir config.publicDir
) )
const relativePath = slash(path.relative(srcDir, file))
const payload: PageDataPayload = { const payload: PageDataPayload = {
path: `/${slash(path.relative(srcDir, file))}`, path: `/${siteConfig.rewrites.map[relativePath] || relativePath}`,
pageData pageData
} }

@ -121,7 +121,7 @@ export const staticDataPlugin: Plugin = {
}, },
transform(_code, id) { transform(_code, id) {
if (server && loaderMatch.test(id)) { if (server && loaderMatch.test(id) && '_importGlobMap' in server) {
// register this module as a glob importer // register this module as a glob importer
const { watch } = idToLoaderModulesMap[id]! const { watch } = idToLoaderModulesMap[id]!
if (watch) { if (watch) {

@ -28,7 +28,7 @@
* custom containers. * custom containers.
* *
* - `default`: The color used purely for subtle indication without any * - `default`: The color used purely for subtle indication without any
* special meanings attched to it such as bg color for menu hover state. * special meanings attached to it such as bg color for menu hover state.
* *
* - `brand`: Used for primary brand colors, such as link text, button with * - `brand`: Used for primary brand colors, such as link text, button with
* brand theme, etc. * brand theme, etc.

Loading…
Cancel
Save