@vuepress/core 2.0.0-rc.1 → 2.0.0-rc.11
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/index.d.ts +28 -55
- package/dist/index.js +130 -165
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -73,9 +73,7 @@ type Page<ExtraPageData extends Record<any, any> = Record<never, never>, ExtraPa
|
|
|
73
73
|
*/
|
|
74
74
|
permalink: string | null;
|
|
75
75
|
/**
|
|
76
|
-
* Custom data to be attached to
|
|
77
|
-
*
|
|
78
|
-
* @see https://router.vuejs.org/api/#meta
|
|
76
|
+
* Custom data to be attached to route record
|
|
79
77
|
*/
|
|
80
78
|
routeMeta: Record<string, unknown>;
|
|
81
79
|
/**
|
|
@@ -107,25 +105,19 @@ type Page<ExtraPageData extends Record<any, any> = Record<never, never>, ExtraPa
|
|
|
107
105
|
*/
|
|
108
106
|
componentFilePathRelative: string;
|
|
109
107
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* Only take effect in webpack
|
|
108
|
+
* Chunk file path
|
|
113
109
|
*/
|
|
114
|
-
|
|
110
|
+
chunkFilePath: string;
|
|
115
111
|
/**
|
|
116
|
-
*
|
|
112
|
+
* Chunk file path relative to temp directory
|
|
117
113
|
*/
|
|
118
|
-
|
|
114
|
+
chunkFilePathRelative: string;
|
|
119
115
|
/**
|
|
120
|
-
*
|
|
121
|
-
*/
|
|
122
|
-
dataFilePathRelative: string;
|
|
123
|
-
/**
|
|
124
|
-
* Page data file chunk name
|
|
116
|
+
* Chunk name
|
|
125
117
|
*
|
|
126
|
-
*
|
|
118
|
+
* This will only take effect in webpack
|
|
127
119
|
*/
|
|
128
|
-
|
|
120
|
+
chunkName: string;
|
|
129
121
|
/**
|
|
130
122
|
* Rendered html file path
|
|
131
123
|
*/
|
|
@@ -557,29 +549,19 @@ interface BuildApp extends App {
|
|
|
557
549
|
declare const prepareClientConfigs: (app: App) => Promise<void>;
|
|
558
550
|
|
|
559
551
|
/**
|
|
560
|
-
* Generate page
|
|
561
|
-
*/
|
|
562
|
-
declare const preparePageComponent: (app: App, page: Page) => Promise<void>;
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* Generate page data temp file of a single page
|
|
552
|
+
* Generate page chunk temp file of a single page
|
|
566
553
|
*/
|
|
567
|
-
declare const
|
|
554
|
+
declare const preparePageChunk: (app: App, page: Page) => Promise<void>;
|
|
568
555
|
|
|
569
556
|
/**
|
|
570
|
-
* Generate page
|
|
571
|
-
*/
|
|
572
|
-
declare const preparePagesComponents: (app: App) => Promise<void>;
|
|
573
|
-
|
|
574
|
-
/**
|
|
575
|
-
* Generate page path to page data map temp file
|
|
557
|
+
* Generate page component temp file of a single page
|
|
576
558
|
*/
|
|
577
|
-
declare const
|
|
559
|
+
declare const preparePageComponent: (app: App, page: Page) => Promise<void>;
|
|
578
560
|
|
|
579
561
|
/**
|
|
580
562
|
* Generate routes temp file
|
|
581
563
|
*/
|
|
582
|
-
declare const
|
|
564
|
+
declare const prepareRoutes: (app: App) => Promise<void>;
|
|
583
565
|
|
|
584
566
|
/**
|
|
585
567
|
* Generate site data temp file
|
|
@@ -597,6 +579,7 @@ declare const appInit: (app: App) => Promise<void>;
|
|
|
597
579
|
* Prepare files for development or build
|
|
598
580
|
*
|
|
599
581
|
* - page components
|
|
582
|
+
* - page chunks
|
|
600
583
|
* - routes
|
|
601
584
|
* - site data
|
|
602
585
|
* - other files that generated by plugins
|
|
@@ -705,30 +688,27 @@ declare const renderPageContent: ({ app, content, filePath, filePathRelative, op
|
|
|
705
688
|
};
|
|
706
689
|
|
|
707
690
|
/**
|
|
708
|
-
* Resolve page
|
|
691
|
+
* Resolve page data file path
|
|
709
692
|
*/
|
|
710
|
-
declare const
|
|
693
|
+
declare const resolvePageChunkInfo: ({ app, htmlFilePathRelative, }: {
|
|
711
694
|
app: App;
|
|
712
695
|
htmlFilePathRelative: string;
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
}>;
|
|
696
|
+
}) => {
|
|
697
|
+
chunkFilePath: string;
|
|
698
|
+
chunkFilePathRelative: string;
|
|
699
|
+
chunkName: string;
|
|
700
|
+
};
|
|
719
701
|
|
|
720
702
|
/**
|
|
721
|
-
* Resolve page
|
|
703
|
+
* Resolve page component and related info
|
|
722
704
|
*/
|
|
723
|
-
declare const
|
|
705
|
+
declare const resolvePageComponentInfo: ({ app, htmlFilePathRelative, }: {
|
|
724
706
|
app: App;
|
|
725
707
|
htmlFilePathRelative: string;
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
dataFileChunkName: string;
|
|
731
|
-
};
|
|
708
|
+
}) => Promise<{
|
|
709
|
+
componentFilePath: string;
|
|
710
|
+
componentFilePathRelative: string;
|
|
711
|
+
}>;
|
|
732
712
|
|
|
733
713
|
/**
|
|
734
714
|
* Resolve page date according to frontmatter or file path
|
|
@@ -770,13 +750,6 @@ declare const resolvePageHtmlInfo: ({ app, path: pagePath, }: {
|
|
|
770
750
|
htmlFilePathRelative: string;
|
|
771
751
|
};
|
|
772
752
|
|
|
773
|
-
/**
|
|
774
|
-
* Resolve page key to identify the page
|
|
775
|
-
*/
|
|
776
|
-
declare const resolvePageKey: ({ path }: {
|
|
777
|
-
path: string;
|
|
778
|
-
}) => string;
|
|
779
|
-
|
|
780
753
|
/**
|
|
781
754
|
* Resolve language of page
|
|
782
755
|
*/
|
|
@@ -842,4 +815,4 @@ declare const normalizeAliasDefineHook: (hook: AliasDefineHook['exposed']) => Al
|
|
|
842
815
|
*/
|
|
843
816
|
declare const normalizeClientConfigFileHook: (hook: ClientConfigFileHook['exposed']) => ClientConfigFileHook['normalized'];
|
|
844
817
|
|
|
845
|
-
export { type AliasDefineHook, type App, type AppConfig, type AppConfigBuild, type AppConfigCommon, type AppConfigDev, type AppDir, type AppDirFunction, type AppEnv, type AppOptions, type AppWriteTemp, type BuildApp, type Bundler, type ClientConfigFileHook, type DevApp, type ExtendsHook, type Hook, type HookItem, type HookQueue, type Hooks, type HooksExposed, type HooksName, type HooksNormalized, type HooksResult, type LifeCycleHook, type Page, type PageOptions, type Plugin, type PluginApi, type PluginConfig, type PluginFunction, type PluginObject, type Theme, type ThemeFunction, type ThemeInfo, type ThemeObject, appInit, appPrepare, appUse, createAppDirFunction, createBaseApp, createBuildApp, createDevApp, createHookQueue, createPage, createPluginApi, createPluginApiHooks, createPluginApiRegisterHooks, inferPagePath, normalizeAliasDefineHook, normalizeClientConfigFileHook, prepareClientConfigs,
|
|
818
|
+
export { type AliasDefineHook, type App, type AppConfig, type AppConfigBuild, type AppConfigCommon, type AppConfigDev, type AppDir, type AppDirFunction, type AppEnv, type AppOptions, type AppWriteTemp, type BuildApp, type Bundler, type ClientConfigFileHook, type DevApp, type ExtendsHook, type Hook, type HookItem, type HookQueue, type Hooks, type HooksExposed, type HooksName, type HooksNormalized, type HooksResult, type LifeCycleHook, type Page, type PageOptions, type Plugin, type PluginApi, type PluginConfig, type PluginFunction, type PluginObject, type Theme, type ThemeFunction, type ThemeInfo, type ThemeObject, appInit, appPrepare, appUse, createAppDirFunction, createBaseApp, createBuildApp, createDevApp, createHookQueue, createPage, createPluginApi, createPluginApiHooks, createPluginApiRegisterHooks, inferPagePath, normalizeAliasDefineHook, normalizeClientConfigFileHook, prepareClientConfigs, preparePageChunk, preparePageComponent, prepareRoutes, prepareSiteData, renderPageContent, resolveAppDir, resolveAppEnv, resolveAppOptions, resolveAppPages, resolveAppSiteData, resolveAppVersion, resolveAppWriteTemp, resolvePageChunkInfo, resolvePageComponentInfo, resolvePageDate, resolvePageFileContent, resolvePageFilePath, resolvePageHtmlInfo, resolvePageLang, resolvePagePath, resolvePagePermalink, resolvePageRouteMeta, resolvePageSlug, resolvePluginObject, resolveThemeInfo };
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,32 @@ ${clientConfigFiles.map((_, index) => ` clientConfig${index},`).join("\n")}
|
|
|
10
10
|
await app.writeTemp("internal/clientConfigs.js", content);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
// src/app/prepare/preparePageChunk.ts
|
|
14
|
+
var HMR_CODE = `
|
|
15
|
+
if (import.meta.webpackHot) {
|
|
16
|
+
import.meta.webpackHot.accept()
|
|
17
|
+
if (__VUE_HMR_RUNTIME__.updatePageData) {
|
|
18
|
+
__VUE_HMR_RUNTIME__.updatePageData(data)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (import.meta.hot) {
|
|
23
|
+
import.meta.hot.accept(({ data }) => {
|
|
24
|
+
__VUE_HMR_RUNTIME__.updatePageData(data)
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
var preparePageChunk = async (app, page) => {
|
|
29
|
+
let content = `import comp from ${JSON.stringify(page.componentFilePath)}
|
|
30
|
+
const data = JSON.parse(${JSON.stringify(JSON.stringify(page.data))})
|
|
31
|
+
export { comp, data }
|
|
32
|
+
`;
|
|
33
|
+
if (app.env.isDev) {
|
|
34
|
+
content += HMR_CODE;
|
|
35
|
+
}
|
|
36
|
+
await app.writeTemp(page.chunkFilePathRelative, content);
|
|
37
|
+
};
|
|
38
|
+
|
|
13
39
|
// src/app/prepare/preparePageComponent.ts
|
|
14
40
|
var preparePageComponent = async (app, page) => {
|
|
15
41
|
await app.writeTemp(
|
|
@@ -27,99 +53,67 @@ var preparePageComponent = async (app, page) => {
|
|
|
27
53
|
);
|
|
28
54
|
};
|
|
29
55
|
|
|
30
|
-
// src/app/prepare/
|
|
31
|
-
|
|
56
|
+
// src/app/prepare/prepareRoutes.ts
|
|
57
|
+
import { normalizeRoutePath } from "@vuepress/shared";
|
|
58
|
+
var HMR_CODE2 = `
|
|
32
59
|
if (import.meta.webpackHot) {
|
|
33
60
|
import.meta.webpackHot.accept()
|
|
34
|
-
if (__VUE_HMR_RUNTIME__.
|
|
35
|
-
__VUE_HMR_RUNTIME__.
|
|
61
|
+
if (__VUE_HMR_RUNTIME__.updateRoutes) {
|
|
62
|
+
__VUE_HMR_RUNTIME__.updateRoutes(routes)
|
|
63
|
+
}
|
|
64
|
+
if (__VUE_HMR_RUNTIME__.updateRedirects) {
|
|
65
|
+
__VUE_HMR_RUNTIME__.updateRedirects(redirects)
|
|
36
66
|
}
|
|
37
67
|
}
|
|
38
68
|
|
|
39
69
|
if (import.meta.hot) {
|
|
40
|
-
import.meta.hot.accept(({
|
|
41
|
-
__VUE_HMR_RUNTIME__.
|
|
70
|
+
import.meta.hot.accept(({ routes, redirects }) => {
|
|
71
|
+
__VUE_HMR_RUNTIME__.updateRoutes(routes)
|
|
72
|
+
__VUE_HMR_RUNTIME__.updateRedirects(redirects)
|
|
42
73
|
})
|
|
43
74
|
}
|
|
44
75
|
`;
|
|
45
|
-
var
|
|
46
|
-
let content = `export const data = JSON.parse(${JSON.stringify(
|
|
47
|
-
JSON.stringify(page.data)
|
|
48
|
-
)})
|
|
49
|
-
`;
|
|
50
|
-
if (app.env.isDev) {
|
|
51
|
-
content += HMR_CODE;
|
|
52
|
-
}
|
|
53
|
-
await app.writeTemp(page.dataFilePathRelative, content);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// src/app/prepare/preparePagesComponents.ts
|
|
57
|
-
var preparePagesComponents = async (app) => {
|
|
58
|
-
const content = `import { defineAsyncComponent } from 'vue'
|
|
59
|
-
|
|
60
|
-
export const pagesComponents = {${app.pages.map(
|
|
61
|
-
({ key, path: path9, componentFilePath, componentFileChunkName }) => `
|
|
62
|
-
// path: ${path9}
|
|
63
|
-
${JSON.stringify(key)}: defineAsyncComponent(() => import(${componentFileChunkName ? `/* webpackChunkName: "${componentFileChunkName}" */` : ""}${JSON.stringify(componentFilePath)})),`
|
|
64
|
-
).join("")}
|
|
65
|
-
}
|
|
66
|
-
`;
|
|
67
|
-
await app.writeTemp("internal/pagesComponents.js", content);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
// src/app/prepare/preparePagesData.ts
|
|
71
|
-
var preparePagesData = async (app) => {
|
|
72
|
-
const content = `export const pagesData = {${app.pages.map(
|
|
73
|
-
({ key, path: path9, dataFilePath, dataFileChunkName }) => `
|
|
74
|
-
// path: ${path9}
|
|
75
|
-
${JSON.stringify(key)}: () => import(${dataFileChunkName ? `/* webpackChunkName: "${dataFileChunkName}" */` : ""}${JSON.stringify(dataFilePath)}).then(({ data }) => data),`
|
|
76
|
-
).join("")}
|
|
77
|
-
}
|
|
78
|
-
`;
|
|
79
|
-
await app.writeTemp("internal/pagesData.js", content);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// src/app/prepare/preparePagesRoutes.ts
|
|
83
|
-
import { ensureLeadingSlash } from "@vuepress/shared";
|
|
84
|
-
var resolvePageRouteItem = ({
|
|
85
|
-
key,
|
|
86
|
-
path: path9,
|
|
87
|
-
pathInferred,
|
|
88
|
-
filePathRelative,
|
|
89
|
-
routeMeta
|
|
90
|
-
}) => {
|
|
76
|
+
var resolvePageRedirects = ({ path: path9, pathInferred }) => {
|
|
91
77
|
const redirectsSet = /* @__PURE__ */ new Set();
|
|
92
|
-
|
|
78
|
+
const addRedirect = (redirect) => {
|
|
79
|
+
const normalizedPath = normalizeRoutePath(redirect);
|
|
80
|
+
if (normalizedPath === path9)
|
|
81
|
+
return;
|
|
82
|
+
const encodedPath = encodeURI(normalizedPath);
|
|
83
|
+
if (encodedPath === path9)
|
|
84
|
+
return;
|
|
85
|
+
redirectsSet.add(redirect);
|
|
86
|
+
};
|
|
93
87
|
if (pathInferred !== null) {
|
|
94
|
-
|
|
95
|
-
redirectsSet.add(encodeURI(pathInferred));
|
|
96
|
-
}
|
|
97
|
-
if (filePathRelative !== null) {
|
|
98
|
-
const filenamePath = ensureLeadingSlash(filePathRelative);
|
|
99
|
-
redirectsSet.add(filenamePath);
|
|
100
|
-
redirectsSet.add(encodeURI(filenamePath));
|
|
88
|
+
addRedirect(encodeURI(pathInferred));
|
|
101
89
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
90
|
+
return Array.from(redirectsSet);
|
|
91
|
+
};
|
|
92
|
+
var prepareRoutes = async (app) => {
|
|
93
|
+
let content = `export const redirects = JSON.parse(${JSON.stringify(
|
|
94
|
+
JSON.stringify(
|
|
95
|
+
Object.fromEntries(
|
|
96
|
+
app.pages.flatMap(
|
|
97
|
+
(page) => resolvePageRedirects(page).map((redirect) => [redirect, page.path])
|
|
98
|
+
)
|
|
99
|
+
)
|
|
109
100
|
)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
]
|
|
101
|
+
)})
|
|
102
|
+
|
|
103
|
+
export const routes = Object.fromEntries([
|
|
104
|
+
${app.pages.map(
|
|
105
|
+
({ chunkFilePath, chunkName, path: path9, routeMeta }) => ` [${JSON.stringify(path9)}, { loader: () => import(${chunkName ? `/* webpackChunkName: "${chunkName}" */` : ""}${JSON.stringify(chunkFilePath)}), meta: ${JSON.stringify(routeMeta)} }],`
|
|
106
|
+
).join("\n")}
|
|
107
|
+
]);
|
|
117
108
|
`;
|
|
118
|
-
|
|
109
|
+
if (app.env.isDev) {
|
|
110
|
+
content += HMR_CODE2;
|
|
111
|
+
}
|
|
112
|
+
await app.writeTemp("internal/routes.js", content);
|
|
119
113
|
};
|
|
120
114
|
|
|
121
115
|
// src/app/prepare/prepareSiteData.ts
|
|
122
|
-
var
|
|
116
|
+
var HMR_CODE3 = `
|
|
123
117
|
if (import.meta.webpackHot) {
|
|
124
118
|
import.meta.webpackHot.accept()
|
|
125
119
|
if (__VUE_HMR_RUNTIME__.updateSiteData) {
|
|
@@ -139,7 +133,7 @@ var prepareSiteData = async (app) => {
|
|
|
139
133
|
)})
|
|
140
134
|
`;
|
|
141
135
|
if (app.env.isDev) {
|
|
142
|
-
content +=
|
|
136
|
+
content += HMR_CODE3;
|
|
143
137
|
}
|
|
144
138
|
await app.writeTemp("internal/siteData.js", content);
|
|
145
139
|
};
|
|
@@ -163,7 +157,7 @@ var resolveAppMarkdown = async (app) => {
|
|
|
163
157
|
import { debug as debug2, globby } from "@vuepress/utils";
|
|
164
158
|
|
|
165
159
|
// src/page/inferPagePath.ts
|
|
166
|
-
import { ensureLeadingSlash
|
|
160
|
+
import { ensureLeadingSlash, resolveLocalePath } from "@vuepress/shared";
|
|
167
161
|
var inferPagePath = ({
|
|
168
162
|
app,
|
|
169
163
|
filePathRelative
|
|
@@ -174,7 +168,7 @@ var inferPagePath = ({
|
|
|
174
168
|
pathLocale: "/"
|
|
175
169
|
};
|
|
176
170
|
}
|
|
177
|
-
const pathInferred =
|
|
171
|
+
const pathInferred = ensureLeadingSlash(filePathRelative).replace(/\.md$/, ".html").replace(/\/(README|index).html$/i, "/");
|
|
178
172
|
const pathLocale = resolveLocalePath(app.siteData.locales, pathInferred);
|
|
179
173
|
return {
|
|
180
174
|
pathInferred,
|
|
@@ -233,40 +227,36 @@ var renderPageContent = ({
|
|
|
233
227
|
};
|
|
234
228
|
};
|
|
235
229
|
|
|
236
|
-
// src/page/
|
|
237
|
-
import { path } from "@vuepress/utils";
|
|
238
|
-
var
|
|
230
|
+
// src/page/resolvePageChunkInfo.ts
|
|
231
|
+
import { path, transformPathToFileName } from "@vuepress/utils";
|
|
232
|
+
var resolvePageChunkInfo = ({
|
|
239
233
|
app,
|
|
240
|
-
htmlFilePathRelative
|
|
241
|
-
key
|
|
234
|
+
htmlFilePathRelative
|
|
242
235
|
}) => {
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
);
|
|
247
|
-
const componentFilePath = app.dir.temp(componentFilePathRelative);
|
|
248
|
-
const componentFileChunkName = key;
|
|
236
|
+
const chunkFilePathRelative = path.join("pages", `${htmlFilePathRelative}.js`);
|
|
237
|
+
const chunkFilePath = app.dir.temp(chunkFilePathRelative);
|
|
238
|
+
const chunkName = transformPathToFileName(htmlFilePathRelative);
|
|
249
239
|
return {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
240
|
+
chunkFilePath,
|
|
241
|
+
chunkFilePathRelative,
|
|
242
|
+
chunkName
|
|
253
243
|
};
|
|
254
244
|
};
|
|
255
245
|
|
|
256
|
-
// src/page/
|
|
246
|
+
// src/page/resolvePageComponentInfo.ts
|
|
257
247
|
import { path as path2 } from "@vuepress/utils";
|
|
258
|
-
var
|
|
248
|
+
var resolvePageComponentInfo = async ({
|
|
259
249
|
app,
|
|
260
|
-
htmlFilePathRelative
|
|
261
|
-
key
|
|
250
|
+
htmlFilePathRelative
|
|
262
251
|
}) => {
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
252
|
+
const componentFilePathRelative = path2.join(
|
|
253
|
+
"pages",
|
|
254
|
+
`${htmlFilePathRelative}.vue`
|
|
255
|
+
);
|
|
256
|
+
const componentFilePath = app.dir.temp(componentFilePathRelative);
|
|
266
257
|
return {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
dataFileChunkName
|
|
258
|
+
componentFilePath,
|
|
259
|
+
componentFilePathRelative
|
|
270
260
|
};
|
|
271
261
|
};
|
|
272
262
|
|
|
@@ -366,8 +356,9 @@ var resolvePageHtmlInfo = ({
|
|
|
366
356
|
app,
|
|
367
357
|
path: pagePath
|
|
368
358
|
}) => {
|
|
359
|
+
const path9 = decodeURI(pagePath);
|
|
369
360
|
const htmlFilePathRelative = removeLeadingSlash(
|
|
370
|
-
|
|
361
|
+
path9.endsWith("/") ? path9 + "index.html" : path9.endsWith(".html") ? path9 : path9 + ".html"
|
|
371
362
|
);
|
|
372
363
|
const htmlFilePath = app.dir.dest(htmlFilePathRelative);
|
|
373
364
|
return {
|
|
@@ -376,10 +367,6 @@ var resolvePageHtmlInfo = ({
|
|
|
376
367
|
};
|
|
377
368
|
};
|
|
378
369
|
|
|
379
|
-
// src/page/resolvePageKey.ts
|
|
380
|
-
import { hash } from "@vuepress/utils";
|
|
381
|
-
var resolvePageKey = ({ path: path9 }) => `v-${hash(path9)}`;
|
|
382
|
-
|
|
383
370
|
// src/page/resolvePageLang.ts
|
|
384
371
|
import { isString as isString2 } from "@vuepress/shared";
|
|
385
372
|
var resolvePageLang = ({
|
|
@@ -394,27 +381,23 @@ var resolvePageLang = ({
|
|
|
394
381
|
};
|
|
395
382
|
|
|
396
383
|
// src/page/resolvePagePath.ts
|
|
397
|
-
import { ensureEndingSlash } from "@vuepress/shared";
|
|
398
384
|
import { logger as logger2, sanitizeFileName } from "@vuepress/utils";
|
|
399
385
|
var resolvePagePath = ({
|
|
400
386
|
permalink,
|
|
401
387
|
pathInferred,
|
|
402
388
|
options
|
|
403
389
|
}) => {
|
|
404
|
-
|
|
390
|
+
const pagePath = options.path || permalink || pathInferred;
|
|
405
391
|
if (!pagePath) {
|
|
406
392
|
throw logger2.createError(
|
|
407
393
|
`page path is empty, page options: ${JSON.stringify(options, null, 2)}`
|
|
408
394
|
);
|
|
409
395
|
}
|
|
410
|
-
if (!pagePath.endsWith(".html")) {
|
|
411
|
-
pagePath = ensureEndingSlash(pagePath);
|
|
412
|
-
}
|
|
413
396
|
return encodeURI(pagePath.split("/").map(sanitizeFileName).join("/"));
|
|
414
397
|
};
|
|
415
398
|
|
|
416
399
|
// src/page/resolvePagePermalink.ts
|
|
417
|
-
import { ensureLeadingSlash as
|
|
400
|
+
import { ensureLeadingSlash as ensureLeadingSlash2, isString as isString3 } from "@vuepress/shared";
|
|
418
401
|
import { path as path5 } from "@vuepress/utils";
|
|
419
402
|
var resolvePagePermalink = ({
|
|
420
403
|
app,
|
|
@@ -424,11 +407,17 @@ var resolvePagePermalink = ({
|
|
|
424
407
|
pathInferred,
|
|
425
408
|
pathLocale
|
|
426
409
|
}) => {
|
|
410
|
+
if (frontmatter.permalink === null) {
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
427
413
|
if (isString3(frontmatter.permalink)) {
|
|
428
414
|
return frontmatter.permalink;
|
|
429
415
|
}
|
|
430
|
-
|
|
431
|
-
|
|
416
|
+
if (frontmatter.permalinkPattern === null) {
|
|
417
|
+
return null;
|
|
418
|
+
}
|
|
419
|
+
const permalinkPattern = frontmatter.permalinkPattern || app.options.permalinkPattern;
|
|
420
|
+
if (!isString3(permalinkPattern)) {
|
|
432
421
|
return null;
|
|
433
422
|
}
|
|
434
423
|
const [year, month, day] = date.split("-");
|
|
@@ -436,19 +425,7 @@ var resolvePagePermalink = ({
|
|
|
436
425
|
pathLocale,
|
|
437
426
|
permalinkPattern.replace(/:year/, year).replace(/:month/, month).replace(/:day/, day).replace(/:slug/, slug).replace(/:raw/, pathInferred?.replace(/^\//, "") ?? "")
|
|
438
427
|
);
|
|
439
|
-
return
|
|
440
|
-
};
|
|
441
|
-
var getPermalinkPattern = ({
|
|
442
|
-
app,
|
|
443
|
-
frontmatter
|
|
444
|
-
}) => {
|
|
445
|
-
if (frontmatter.permalinkPattern === null) {
|
|
446
|
-
return null;
|
|
447
|
-
}
|
|
448
|
-
if (isString3(frontmatter.permalinkPattern)) {
|
|
449
|
-
return frontmatter.permalinkPattern;
|
|
450
|
-
}
|
|
451
|
-
return app.options.permalinkPattern;
|
|
428
|
+
return ensureLeadingSlash2(link);
|
|
452
429
|
};
|
|
453
430
|
|
|
454
431
|
// src/page/resolvePageRouteMeta.ts
|
|
@@ -508,25 +485,18 @@ var createPage = async (app, options) => {
|
|
|
508
485
|
pathLocale
|
|
509
486
|
});
|
|
510
487
|
const path9 = resolvePagePath({ permalink, pathInferred, options });
|
|
511
|
-
const key = resolvePageKey({ path: path9 });
|
|
512
488
|
const { htmlFilePath, htmlFilePathRelative } = resolvePageHtmlInfo({
|
|
513
489
|
app,
|
|
514
490
|
path: path9
|
|
515
491
|
});
|
|
516
|
-
const {
|
|
517
|
-
componentFilePath,
|
|
518
|
-
componentFilePathRelative,
|
|
519
|
-
componentFileChunkName
|
|
520
|
-
} = await resolvePageComponentInfo({
|
|
492
|
+
const { componentFilePath, componentFilePathRelative } = await resolvePageComponentInfo({
|
|
521
493
|
app,
|
|
522
|
-
htmlFilePathRelative
|
|
523
|
-
key
|
|
494
|
+
htmlFilePathRelative
|
|
524
495
|
});
|
|
525
|
-
const {
|
|
496
|
+
const { chunkFilePath, chunkFilePathRelative, chunkName } = resolvePageChunkInfo({ app, htmlFilePathRelative });
|
|
526
497
|
const page = {
|
|
527
498
|
// page data
|
|
528
499
|
data: {
|
|
529
|
-
key,
|
|
530
500
|
path: path9,
|
|
531
501
|
title,
|
|
532
502
|
lang,
|
|
@@ -534,7 +504,6 @@ var createPage = async (app, options) => {
|
|
|
534
504
|
headers
|
|
535
505
|
},
|
|
536
506
|
// base fields
|
|
537
|
-
key,
|
|
538
507
|
path: path9,
|
|
539
508
|
title,
|
|
540
509
|
lang,
|
|
@@ -558,10 +527,9 @@ var createPage = async (app, options) => {
|
|
|
558
527
|
filePathRelative,
|
|
559
528
|
componentFilePath,
|
|
560
529
|
componentFilePathRelative,
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
dataFileChunkName,
|
|
530
|
+
chunkFilePath,
|
|
531
|
+
chunkFilePathRelative,
|
|
532
|
+
chunkName,
|
|
565
533
|
htmlFilePath,
|
|
566
534
|
htmlFilePathRelative
|
|
567
535
|
};
|
|
@@ -580,13 +548,15 @@ var resolveAppPages = async (app) => {
|
|
|
580
548
|
const pages = await Promise.all(
|
|
581
549
|
pageFilePaths.map((filePath) => createPage(app, { filePath }))
|
|
582
550
|
);
|
|
583
|
-
|
|
551
|
+
const notFoundPage = pages.find((page) => page.path === "/404.html");
|
|
552
|
+
if (notFoundPage) {
|
|
553
|
+
notFoundPage.frontmatter.layout ??= "NotFound";
|
|
554
|
+
} else {
|
|
584
555
|
pages.push(
|
|
585
556
|
await createPage(app, {
|
|
586
557
|
path: "/404.html",
|
|
587
|
-
frontmatter: {
|
|
588
|
-
|
|
589
|
-
}
|
|
558
|
+
frontmatter: { layout: "NotFound" },
|
|
559
|
+
content: "404 Not Found"
|
|
590
560
|
})
|
|
591
561
|
);
|
|
592
562
|
}
|
|
@@ -610,17 +580,15 @@ import { debug as debug4 } from "@vuepress/utils";
|
|
|
610
580
|
var log4 = debug4("vuepress:core/app");
|
|
611
581
|
var appPrepare = async (app) => {
|
|
612
582
|
log4("prepare start");
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
await prepareSiteData(app);
|
|
623
|
-
await prepareClientConfigs(app);
|
|
583
|
+
await Promise.all([
|
|
584
|
+
...app.pages.flatMap((page) => [
|
|
585
|
+
preparePageComponent(app, page),
|
|
586
|
+
preparePageChunk(app, page)
|
|
587
|
+
]),
|
|
588
|
+
prepareRoutes(app),
|
|
589
|
+
prepareSiteData(app),
|
|
590
|
+
prepareClientConfigs(app)
|
|
591
|
+
]);
|
|
624
592
|
await app.pluginApi.hooks.onPrepared.process(app);
|
|
625
593
|
log4("prepare finish");
|
|
626
594
|
};
|
|
@@ -1008,11 +976,9 @@ export {
|
|
|
1008
976
|
normalizeAliasDefineHook,
|
|
1009
977
|
normalizeClientConfigFileHook,
|
|
1010
978
|
prepareClientConfigs,
|
|
979
|
+
preparePageChunk,
|
|
1011
980
|
preparePageComponent,
|
|
1012
|
-
|
|
1013
|
-
preparePagesComponents,
|
|
1014
|
-
preparePagesData,
|
|
1015
|
-
preparePagesRoutes,
|
|
981
|
+
prepareRoutes,
|
|
1016
982
|
prepareSiteData,
|
|
1017
983
|
renderPageContent,
|
|
1018
984
|
resolveAppDir,
|
|
@@ -1022,13 +988,12 @@ export {
|
|
|
1022
988
|
resolveAppSiteData,
|
|
1023
989
|
resolveAppVersion,
|
|
1024
990
|
resolveAppWriteTemp,
|
|
991
|
+
resolvePageChunkInfo,
|
|
1025
992
|
resolvePageComponentInfo,
|
|
1026
|
-
resolvePageDataInfo,
|
|
1027
993
|
resolvePageDate,
|
|
1028
994
|
resolvePageFileContent,
|
|
1029
995
|
resolvePageFilePath,
|
|
1030
996
|
resolvePageHtmlInfo,
|
|
1031
|
-
resolvePageKey,
|
|
1032
997
|
resolvePageLang,
|
|
1033
998
|
resolvePagePath,
|
|
1034
999
|
resolvePagePermalink,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/core",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.11",
|
|
4
4
|
"description": "Core package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"vue": "^3.4.
|
|
31
|
-
"@vuepress/client": "2.0.0-rc.
|
|
32
|
-
"@vuepress/markdown": "2.0.0-rc.
|
|
33
|
-
"@vuepress/shared": "2.0.0-rc.
|
|
34
|
-
"@vuepress/utils": "2.0.0-rc.
|
|
30
|
+
"vue": "^3.4.27",
|
|
31
|
+
"@vuepress/client": "2.0.0-rc.11",
|
|
32
|
+
"@vuepress/markdown": "2.0.0-rc.11",
|
|
33
|
+
"@vuepress/shared": "2.0.0-rc.11",
|
|
34
|
+
"@vuepress/utils": "2.0.0-rc.11"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|