vitepress 0.21.0 → 0.21.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/cli.js +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/{serve-de785cbb.js → serve-9731a371.js} +29 -6
- package/package.json +1 -1
- package/types/index.d.ts +0 -2
- package/types/shared.d.ts +16 -16
package/dist/node/cli.js
CHANGED
package/dist/node/index.js
CHANGED
|
@@ -12306,12 +12306,19 @@ const SHARED_PATH = path__default["default"].join(DIST_CLIENT_PATH, "shared");
|
|
|
12306
12306
|
const DEFAULT_THEME_PATH = path__default["default"].join(DIST_CLIENT_PATH, "theme-default");
|
|
12307
12307
|
const SITE_DATA_ID = "@siteData";
|
|
12308
12308
|
const SITE_DATA_REQUEST_PATH = "/" + SITE_DATA_ID;
|
|
12309
|
-
|
|
12309
|
+
const vueRuntimePath = "vue/dist/vue.runtime.esm-bundler.js";
|
|
12310
|
+
function resolveAliases(root, themeDir) {
|
|
12310
12311
|
const paths = {
|
|
12311
12312
|
"/@theme": themeDir,
|
|
12312
12313
|
"/@shared": SHARED_PATH,
|
|
12313
12314
|
[SITE_DATA_ID]: SITE_DATA_REQUEST_PATH
|
|
12314
12315
|
};
|
|
12316
|
+
let vuePath;
|
|
12317
|
+
try {
|
|
12318
|
+
vuePath = require.resolve(vueRuntimePath, { paths: [root] });
|
|
12319
|
+
} catch (e) {
|
|
12320
|
+
vuePath = require.resolve(vueRuntimePath);
|
|
12321
|
+
}
|
|
12315
12322
|
const aliases = [
|
|
12316
12323
|
...Object.keys(paths).map((p) => ({
|
|
12317
12324
|
find: p,
|
|
@@ -12328,7 +12335,7 @@ function resolveAliases(themeDir) {
|
|
|
12328
12335
|
{ find: /^vitepress\//, replacement: PKG_ROOT + "/" },
|
|
12329
12336
|
{
|
|
12330
12337
|
find: /^vue$/,
|
|
12331
|
-
replacement:
|
|
12338
|
+
replacement: vuePath
|
|
12332
12339
|
}
|
|
12333
12340
|
];
|
|
12334
12341
|
return aliases;
|
|
@@ -13373,7 +13380,7 @@ async function resolveConfig(root = process.cwd(), command = "serve", mode = "de
|
|
|
13373
13380
|
outDir,
|
|
13374
13381
|
tempDir: resolve(root, ".temp"),
|
|
13375
13382
|
markdown: userConfig.markdown,
|
|
13376
|
-
alias: resolveAliases(themeDir),
|
|
13383
|
+
alias: resolveAliases(root, themeDir),
|
|
13377
13384
|
vue: userConfig.vue,
|
|
13378
13385
|
vite: userConfig.vite,
|
|
13379
13386
|
shouldPreload: userConfig.shouldPreload,
|
|
@@ -36311,6 +36318,11 @@ const createMarkdownRenderer = (srcDir, options = {}) => {
|
|
|
36311
36318
|
if (options.lineNumbers) {
|
|
36312
36319
|
md.use(lineNumberPlugin);
|
|
36313
36320
|
}
|
|
36321
|
+
const originalRender = md.render;
|
|
36322
|
+
md.render = (...args) => {
|
|
36323
|
+
md.__data = {};
|
|
36324
|
+
return originalRender.call(md, ...args);
|
|
36325
|
+
};
|
|
36314
36326
|
return md;
|
|
36315
36327
|
};
|
|
36316
36328
|
|
|
@@ -36344,7 +36356,6 @@ function createMarkdownToVueRenderFn(srcDir, options = {}, pages, userDefines, i
|
|
|
36344
36356
|
const { content, data: frontmatter } = grayMatter(src);
|
|
36345
36357
|
md.__path = file;
|
|
36346
36358
|
md.__relativePath = relativePath;
|
|
36347
|
-
md.__data = {};
|
|
36348
36359
|
let html = md.render(content);
|
|
36349
36360
|
const data = md.__data;
|
|
36350
36361
|
if (isBuild) {
|
|
@@ -36611,7 +36622,11 @@ function createVitePressPlugin(root, siteConfig, ssr = false, pageToHashMap, cli
|
|
|
36611
36622
|
},
|
|
36612
36623
|
load(id) {
|
|
36613
36624
|
if (id === SITE_DATA_REQUEST_PATH) {
|
|
36614
|
-
|
|
36625
|
+
let data = siteData;
|
|
36626
|
+
if (config.command === "build") {
|
|
36627
|
+
data = __spreadProps$1(__spreadValues$1({}, siteData), { head: [] });
|
|
36628
|
+
}
|
|
36629
|
+
return `export default ${JSON.stringify(JSON.stringify(data))}`;
|
|
36615
36630
|
}
|
|
36616
36631
|
},
|
|
36617
36632
|
transform(code, id) {
|
|
@@ -40052,7 +40067,15 @@ async function renderPage(config, page, result, appChunk, cssChunk, pageToHashMa
|
|
|
40052
40067
|
const routePath = `/${page.replace(/\.md$/, "")}`;
|
|
40053
40068
|
const siteData = resolveSiteDataByRoute(config.site, routePath);
|
|
40054
40069
|
router.go(routePath);
|
|
40055
|
-
|
|
40070
|
+
let rendererPath;
|
|
40071
|
+
try {
|
|
40072
|
+
rendererPath = require.resolve("vue/server-renderer", {
|
|
40073
|
+
paths: [config.root]
|
|
40074
|
+
});
|
|
40075
|
+
} catch (e) {
|
|
40076
|
+
rendererPath = require.resolve("vue/server-renderer");
|
|
40077
|
+
}
|
|
40078
|
+
const content = await require(rendererPath).renderToString(app);
|
|
40056
40079
|
const pageName = page.replace(/\//g, "_");
|
|
40057
40080
|
const pageServerJsFileName = pageName + ".js";
|
|
40058
40081
|
const pageHash = pageToHashMap[pageName.toLowerCase()];
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
package/types/shared.d.ts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
export { DefaultTheme } from './default-theme'
|
|
4
4
|
|
|
5
|
-
export interface
|
|
6
|
-
|
|
7
|
-
title
|
|
8
|
-
description
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
export interface PageData {
|
|
6
|
+
relativePath: string
|
|
7
|
+
title: string
|
|
8
|
+
description: string
|
|
9
|
+
headers: Header[]
|
|
10
|
+
frontmatter: Record<string, any>
|
|
11
|
+
lastUpdated: number
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export interface SiteData<ThemeConfig = any> {
|
|
@@ -49,17 +49,17 @@ export type HeadConfig =
|
|
|
49
49
|
| [string, Record<string, string>]
|
|
50
50
|
| [string, Record<string, string>, string]
|
|
51
51
|
|
|
52
|
-
export interface PageData {
|
|
53
|
-
relativePath: string
|
|
54
|
-
title: string
|
|
55
|
-
description: string
|
|
56
|
-
headers: Header[]
|
|
57
|
-
frontmatter: Record<string, any>
|
|
58
|
-
lastUpdated: number
|
|
59
|
-
}
|
|
60
|
-
|
|
61
52
|
export interface Header {
|
|
62
53
|
level: number
|
|
63
54
|
title: string
|
|
64
55
|
slug: string
|
|
65
56
|
}
|
|
57
|
+
|
|
58
|
+
export interface LocaleConfig {
|
|
59
|
+
lang: string
|
|
60
|
+
title?: string
|
|
61
|
+
description?: string
|
|
62
|
+
head?: HeadConfig[]
|
|
63
|
+
label?: string
|
|
64
|
+
selectText?: string
|
|
65
|
+
}
|