@vuepress/core 2.0.0-beta.27 → 2.0.0-beta.33
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/lib/app/appInit.js +5 -4
- package/lib/app/appUse.js +2 -2
- package/lib/app/createBaseApp.js +23 -26
- package/lib/app/index.d.ts +9 -9
- package/lib/app/index.js +9 -9
- package/lib/app/prepare/preparePagesRoutes.js +4 -4
- package/lib/app/{createAppDir.d.ts → resolveAppDir.d.ts} +2 -2
- package/lib/app/{createAppDir.js → resolveAppDir.js} +4 -4
- package/lib/app/resolveAppEnv.d.ts +5 -0
- package/lib/app/resolveAppEnv.js +12 -0
- package/lib/app/resolveAppMarkdown.d.ts +6 -0
- package/lib/app/resolveAppMarkdown.js +16 -0
- package/lib/app/resolveAppOptions.d.ts +5 -0
- package/lib/app/{createAppOptions.js → resolveAppOptions.js} +7 -7
- package/lib/app/resolveAppPages.d.ts +5 -0
- package/lib/app/{createAppPages.js → resolveAppPages.js} +6 -6
- package/lib/app/resolveAppSiteData.d.ts +7 -0
- package/lib/app/{createAppSiteData.js → resolveAppSiteData.js} +4 -4
- package/lib/app/resolveAppVersion.d.ts +4 -0
- package/lib/app/resolveAppVersion.js +10 -0
- package/lib/app/resolveAppWriteTemp.d.ts +5 -0
- package/lib/app/{createAppWriteTemp.js → resolveAppWriteTemp.js} +4 -4
- package/lib/app/resolvePluginObject.d.ts +5 -0
- package/lib/app/{resolvePlugin.js → resolvePluginObject.js} +5 -5
- package/lib/app/resolvePluginsFromConfig.d.ts +1 -1
- package/lib/app/resolvePluginsFromConfig.js +3 -3
- package/lib/app/resolveThemeInfo.d.ts +2 -2
- package/lib/app/resolveThemeInfo.js +15 -7
- package/lib/app/resolveThemeObject.d.ts +5 -0
- package/lib/app/resolveThemeObject.js +22 -0
- package/lib/app/setupAppPlugins.d.ts +5 -0
- package/lib/app/setupAppPlugins.js +14 -0
- package/lib/app/setupAppTheme.d.ts +5 -0
- package/lib/app/setupAppTheme.js +21 -0
- package/lib/page/createPage.d.ts +1 -1
- package/lib/page/createPage.js +22 -10
- package/lib/page/index.d.ts +1 -2
- package/lib/page/index.js +1 -2
- package/lib/page/resolvePageContent.js +1 -1
- package/lib/page/resolvePageRouteMeta.d.ts +7 -0
- package/lib/page/resolvePageRouteMeta.js +8 -0
- package/lib/pluginApi/createHookQueue.js +1 -1
- package/lib/pluginApi/createPluginApiHooks.js +4 -4
- package/lib/types/app/app.d.ts +16 -14
- package/lib/types/app/options.d.ts +36 -25
- package/lib/types/page.d.ts +9 -3
- package/lib/types/pluginApi/hooks.d.ts +6 -7
- package/lib/types/theme.d.ts +28 -0
- package/package.json +6 -6
- package/lib/app/createAppEnv.d.ts +0 -5
- package/lib/app/createAppEnv.js +0 -12
- package/lib/app/createAppOptions.d.ts +0 -5
- package/lib/app/createAppPages.d.ts +0 -5
- package/lib/app/createAppSiteData.d.ts +0 -7
- package/lib/app/createAppVersion.d.ts +0 -4
- package/lib/app/createAppVersion.js +0 -10
- package/lib/app/createAppWriteTemp.d.ts +0 -5
- package/lib/app/resolvePlugin.d.ts +0 -5
- package/lib/app/resolveTheme.d.ts +0 -5
- package/lib/app/resolveTheme.js +0 -22
- package/lib/page/resolvePageData.d.ts +0 -8
- package/lib/page/resolvePageData.js +0 -23
- package/lib/page/resolvePageOptions.d.ts +0 -8
- package/lib/page/resolvePageOptions.js +0 -15
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupAppTheme = void 0;
|
|
4
|
+
const resolveThemeInfo_1 = require("./resolveThemeInfo");
|
|
5
|
+
/**
|
|
6
|
+
* Setup theme for vuepress app
|
|
7
|
+
*/
|
|
8
|
+
const setupAppTheme = (app, config) => {
|
|
9
|
+
var _a, _b, _c, _d;
|
|
10
|
+
// recursively resolve theme info
|
|
11
|
+
const themeInfo = (0, resolveThemeInfo_1.resolveThemeInfo)(app, app.options.theme, app.options.themeConfig);
|
|
12
|
+
// set up app layouts and templates
|
|
13
|
+
app.layouts = themeInfo.layouts;
|
|
14
|
+
app.options.templateDev =
|
|
15
|
+
(_b = (_a = config.templateDev) !== null && _a !== void 0 ? _a : themeInfo.templateDev) !== null && _b !== void 0 ? _b : app.options.templateDev;
|
|
16
|
+
app.options.templateBuild =
|
|
17
|
+
(_d = (_c = config.templateBuild) !== null && _c !== void 0 ? _c : themeInfo.templateBuild) !== null && _d !== void 0 ? _d : app.options.templateBuild;
|
|
18
|
+
// use theme plugins
|
|
19
|
+
themeInfo.plugins.forEach((plugin) => app.use(plugin));
|
|
20
|
+
};
|
|
21
|
+
exports.setupAppTheme = setupAppTheme;
|
package/lib/page/createPage.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { App, Page, PageOptions } from '../types';
|
|
2
|
-
export declare const createPage: (app: App,
|
|
2
|
+
export declare const createPage: (app: App, options: PageOptions) => Promise<Page>;
|
package/lib/page/createPage.js
CHANGED
|
@@ -6,7 +6,6 @@ const renderPageContent_1 = require("./renderPageContent");
|
|
|
6
6
|
const renderPageExcerpt_1 = require("./renderPageExcerpt");
|
|
7
7
|
const resolvePageComponentInfo_1 = require("./resolvePageComponentInfo");
|
|
8
8
|
const resolvePageContent_1 = require("./resolvePageContent");
|
|
9
|
-
const resolvePageData_1 = require("./resolvePageData");
|
|
10
9
|
const resolvePageDataInfo_1 = require("./resolvePageDataInfo");
|
|
11
10
|
const resolvePageDate_1 = require("./resolvePageDate");
|
|
12
11
|
const resolvePageFileContent_1 = require("./resolvePageFileContent");
|
|
@@ -15,13 +14,13 @@ const resolvePageFrontmatter_1 = require("./resolvePageFrontmatter");
|
|
|
15
14
|
const resolvePageHtmlInfo_1 = require("./resolvePageHtmlInfo");
|
|
16
15
|
const resolvePageKey_1 = require("./resolvePageKey");
|
|
17
16
|
const resolvePageLang_1 = require("./resolvePageLang");
|
|
18
|
-
const resolvePageOptions_1 = require("./resolvePageOptions");
|
|
19
17
|
const resolvePagePath_1 = require("./resolvePagePath");
|
|
20
18
|
const resolvePagePermalink_1 = require("./resolvePagePermalink");
|
|
19
|
+
const resolvePageRouteMeta_1 = require("./resolvePageRouteMeta");
|
|
21
20
|
const resolvePageSlug_1 = require("./resolvePageSlug");
|
|
22
|
-
const createPage = async (app,
|
|
23
|
-
//
|
|
24
|
-
|
|
21
|
+
const createPage = async (app, options) => {
|
|
22
|
+
// plugin hook: extendsPageOptions
|
|
23
|
+
await app.pluginApi.hooks.extendsPageOptions.process(options, app);
|
|
25
24
|
// resolve page file absolute path and relative path
|
|
26
25
|
const { filePath, filePathRelative } = (0, resolvePageFilePath_1.resolvePageFilePath)({
|
|
27
26
|
app,
|
|
@@ -44,13 +43,15 @@ const createPage = async (app, optionsRaw) => {
|
|
|
44
43
|
frontmatter,
|
|
45
44
|
});
|
|
46
45
|
// render page content and extract information
|
|
47
|
-
const { contentRendered, deps, headers, hoistedTags, links, title
|
|
46
|
+
const { contentRendered, deps, headers, hoistedTags, links, title } = await (0, renderPageContent_1.renderPageContent)({
|
|
48
47
|
app,
|
|
49
48
|
content,
|
|
50
49
|
filePath,
|
|
51
50
|
filePathRelative,
|
|
52
51
|
frontmatter,
|
|
53
52
|
});
|
|
53
|
+
// resolve route meta from frontmatter
|
|
54
|
+
const routeMeta = (0, resolvePageRouteMeta_1.resolvePageRouteMeta)({ frontmatter });
|
|
54
55
|
// resolve slug from file path
|
|
55
56
|
const slug = (0, resolvePageSlug_1.resolvePageSlug)({ filePathRelative });
|
|
56
57
|
// resolve date from file path
|
|
@@ -69,7 +70,7 @@ const createPage = async (app, optionsRaw) => {
|
|
|
69
70
|
});
|
|
70
71
|
// resolve page path
|
|
71
72
|
const path = (0, resolvePagePath_1.resolvePagePath)({ permalink, pathInferred, options });
|
|
72
|
-
// resolve
|
|
73
|
+
// resolve page key
|
|
73
74
|
const key = (0, resolvePageKey_1.resolvePageKey)({ path });
|
|
74
75
|
// resolve page rendered html file path
|
|
75
76
|
const { htmlFilePath, htmlFilePathRelative } = (0, resolvePageHtmlInfo_1.resolvePageHtmlInfo)({
|
|
@@ -83,8 +84,18 @@ const createPage = async (app, optionsRaw) => {
|
|
|
83
84
|
htmlFilePathRelative,
|
|
84
85
|
key,
|
|
85
86
|
});
|
|
86
|
-
const { dataFilePath, dataFilePathRelative, dataFileChunkName
|
|
87
|
+
const { dataFilePath, dataFilePathRelative, dataFileChunkName } = (0, resolvePageDataInfo_1.resolvePageDataInfo)({ app, htmlFilePathRelative, key });
|
|
87
88
|
const page = {
|
|
89
|
+
// page data
|
|
90
|
+
data: {
|
|
91
|
+
key,
|
|
92
|
+
path,
|
|
93
|
+
title,
|
|
94
|
+
lang,
|
|
95
|
+
frontmatter,
|
|
96
|
+
excerpt,
|
|
97
|
+
headers,
|
|
98
|
+
},
|
|
88
99
|
// base fields
|
|
89
100
|
key,
|
|
90
101
|
path,
|
|
@@ -103,6 +114,7 @@ const createPage = async (app, optionsRaw) => {
|
|
|
103
114
|
pathInferred,
|
|
104
115
|
pathLocale,
|
|
105
116
|
permalink,
|
|
117
|
+
routeMeta,
|
|
106
118
|
slug,
|
|
107
119
|
// file info
|
|
108
120
|
filePath,
|
|
@@ -116,8 +128,8 @@ const createPage = async (app, optionsRaw) => {
|
|
|
116
128
|
htmlFilePath,
|
|
117
129
|
htmlFilePathRelative,
|
|
118
130
|
};
|
|
119
|
-
//
|
|
120
|
-
|
|
131
|
+
// plugin hook: extendsPage
|
|
132
|
+
await app.pluginApi.hooks.extendsPage.process(page, app);
|
|
121
133
|
return page;
|
|
122
134
|
};
|
|
123
135
|
exports.createPage = createPage;
|
package/lib/page/index.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ export * from './renderPageExcerpt';
|
|
|
5
5
|
export * from './resolvePageComponentInfo';
|
|
6
6
|
export * from './resolvePageContent';
|
|
7
7
|
export * from './resolvePageDataInfo';
|
|
8
|
-
export * from './resolvePageData';
|
|
9
8
|
export * from './resolvePageDate';
|
|
10
9
|
export * from './resolvePageFileContent';
|
|
11
10
|
export * from './resolvePageFilePath';
|
|
@@ -13,7 +12,7 @@ export * from './resolvePageFrontmatter';
|
|
|
13
12
|
export * from './resolvePageHtmlInfo';
|
|
14
13
|
export * from './resolvePageKey';
|
|
15
14
|
export * from './resolvePageLang';
|
|
16
|
-
export * from './resolvePageOptions';
|
|
17
15
|
export * from './resolvePagePath';
|
|
18
16
|
export * from './resolvePagePermalink';
|
|
17
|
+
export * from './resolvePageRouteMeta';
|
|
19
18
|
export * from './resolvePageSlug';
|
package/lib/page/index.js
CHANGED
|
@@ -17,7 +17,6 @@ __exportStar(require("./renderPageExcerpt"), exports);
|
|
|
17
17
|
__exportStar(require("./resolvePageComponentInfo"), exports);
|
|
18
18
|
__exportStar(require("./resolvePageContent"), exports);
|
|
19
19
|
__exportStar(require("./resolvePageDataInfo"), exports);
|
|
20
|
-
__exportStar(require("./resolvePageData"), exports);
|
|
21
20
|
__exportStar(require("./resolvePageDate"), exports);
|
|
22
21
|
__exportStar(require("./resolvePageFileContent"), exports);
|
|
23
22
|
__exportStar(require("./resolvePageFilePath"), exports);
|
|
@@ -25,7 +24,7 @@ __exportStar(require("./resolvePageFrontmatter"), exports);
|
|
|
25
24
|
__exportStar(require("./resolvePageHtmlInfo"), exports);
|
|
26
25
|
__exportStar(require("./resolvePageKey"), exports);
|
|
27
26
|
__exportStar(require("./resolvePageLang"), exports);
|
|
28
|
-
__exportStar(require("./resolvePageOptions"), exports);
|
|
29
27
|
__exportStar(require("./resolvePagePath"), exports);
|
|
30
28
|
__exportStar(require("./resolvePagePermalink"), exports);
|
|
29
|
+
__exportStar(require("./resolvePageRouteMeta"), exports);
|
|
31
30
|
__exportStar(require("./resolvePageSlug"), exports);
|
|
@@ -15,7 +15,7 @@ const resolvePageContent = ({ contentRaw, }) => {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
/* istanbul ignore next */
|
|
18
|
-
const { data, content, excerpt = '' } = matter(contentRaw, {
|
|
18
|
+
const { data, content, excerpt = '', } = matter(contentRaw, {
|
|
19
19
|
excerpt_separator: '<!-- more -->',
|
|
20
20
|
engines: {
|
|
21
21
|
toml: toml.parse.bind(toml),
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolvePageRouteMeta = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Resolve page route meta
|
|
6
|
+
*/
|
|
7
|
+
const resolvePageRouteMeta = ({ frontmatter, }) => { var _a; return (_a = frontmatter.routeMeta) !== null && _a !== void 0 ? _a : {}; };
|
|
8
|
+
exports.resolvePageRouteMeta = resolvePageRouteMeta;
|
|
@@ -22,7 +22,7 @@ const createHookQueue = (name) => {
|
|
|
22
22
|
log(`process ${utils_1.chalk.magenta(name)} from ${utils_1.chalk.magenta(item.pluginName)}`);
|
|
23
23
|
try {
|
|
24
24
|
// process and get the result of the the hook item
|
|
25
|
-
// @ts-
|
|
25
|
+
// @ts-expect-error: the types could not be narrowed correctly
|
|
26
26
|
const result = (await item.hook(...args));
|
|
27
27
|
// push the result to results array
|
|
28
28
|
if (result !== undefined) {
|
|
@@ -8,11 +8,11 @@ const createPluginApiHooks = () => ({
|
|
|
8
8
|
onPrepared: (0, createHookQueue_1.createHookQueue)('onPrepared'),
|
|
9
9
|
onWatched: (0, createHookQueue_1.createHookQueue)('onWatched'),
|
|
10
10
|
onGenerated: (0, createHookQueue_1.createHookQueue)('onGenerated'),
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
extendsPageData: (0, createHookQueue_1.createHookQueue)('extendsPageData'),
|
|
14
|
-
// markdown hooks
|
|
11
|
+
// extends hooks
|
|
12
|
+
extendsMarkdownOptions: (0, createHookQueue_1.createHookQueue)('extendsMarkdownOptions'),
|
|
15
13
|
extendsMarkdown: (0, createHookQueue_1.createHookQueue)('extendsMarkdown'),
|
|
14
|
+
extendsPageOptions: (0, createHookQueue_1.createHookQueue)('extendsPageOptions'),
|
|
15
|
+
extendsPage: (0, createHookQueue_1.createHookQueue)('extendsPage'),
|
|
16
16
|
// client files hooks
|
|
17
17
|
clientAppEnhanceFiles: (0, createHookQueue_1.createHookQueue)('clientAppEnhanceFiles'),
|
|
18
18
|
clientAppRootComponentFiles: (0, createHookQueue_1.createHookQueue)('clientAppRootComponentFiles'),
|
package/lib/types/app/app.d.ts
CHANGED
|
@@ -10,14 +10,6 @@ import type { AppDir, AppEnv, AppWriteTemp } from './utils';
|
|
|
10
10
|
* Vuepress app
|
|
11
11
|
*/
|
|
12
12
|
export interface App {
|
|
13
|
-
/**
|
|
14
|
-
* Version of vuepress core
|
|
15
|
-
*/
|
|
16
|
-
version: string;
|
|
17
|
-
/**
|
|
18
|
-
* Options that filled all optional fields with a default value
|
|
19
|
-
*/
|
|
20
|
-
options: AppOptions;
|
|
21
13
|
/**
|
|
22
14
|
* Directory utils
|
|
23
15
|
*/
|
|
@@ -27,17 +19,21 @@ export interface App {
|
|
|
27
19
|
*/
|
|
28
20
|
env: AppEnv;
|
|
29
21
|
/**
|
|
30
|
-
*
|
|
31
|
-
*/
|
|
32
|
-
siteData: SiteData;
|
|
33
|
-
/**
|
|
34
|
-
* Markdown-it instance
|
|
22
|
+
* Options that filled all optional fields with a default value
|
|
35
23
|
*/
|
|
36
|
-
|
|
24
|
+
options: AppOptions;
|
|
37
25
|
/**
|
|
38
26
|
* Plugin system
|
|
39
27
|
*/
|
|
40
28
|
pluginApi: PluginApi;
|
|
29
|
+
/**
|
|
30
|
+
* Site data, which will be used in client side
|
|
31
|
+
*/
|
|
32
|
+
siteData: SiteData;
|
|
33
|
+
/**
|
|
34
|
+
* Version of vuepress core
|
|
35
|
+
*/
|
|
36
|
+
version: string;
|
|
41
37
|
/**
|
|
42
38
|
* Write temp file
|
|
43
39
|
*/
|
|
@@ -65,6 +61,12 @@ export interface App {
|
|
|
65
61
|
* Only available after initialization
|
|
66
62
|
*/
|
|
67
63
|
layouts: Record<string, string>;
|
|
64
|
+
/**
|
|
65
|
+
* Markdown-it instance.
|
|
66
|
+
*
|
|
67
|
+
* Only available after initialization
|
|
68
|
+
*/
|
|
69
|
+
markdown: Markdown;
|
|
68
70
|
/**
|
|
69
71
|
* Page objects.
|
|
70
72
|
*
|
|
@@ -1,33 +1,44 @@
|
|
|
1
1
|
import type { MarkdownOptions } from '@vuepress/markdown';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SiteData } from '@vuepress/shared';
|
|
3
3
|
import type { BundlerConfig } from '../bundler';
|
|
4
4
|
import type { PluginConfig } from '../plugin';
|
|
5
5
|
import type { ThemeConfig } from '../theme';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Config to create vuepress app
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
bundler: string;
|
|
15
|
-
bundlerConfig: Partial<U>;
|
|
9
|
+
export declare type AppConfig<T extends ThemeConfig = ThemeConfig, U extends BundlerConfig = BundlerConfig> = Partial<SiteData> & AppConfigDev & AppConfigBuild & {
|
|
10
|
+
theme?: string;
|
|
11
|
+
themeConfig?: Partial<T>;
|
|
12
|
+
bundler?: string;
|
|
13
|
+
bundlerConfig?: Partial<U>;
|
|
16
14
|
source: string;
|
|
17
|
-
dest
|
|
18
|
-
temp
|
|
19
|
-
cache
|
|
20
|
-
public
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
dest?: string;
|
|
16
|
+
temp?: string;
|
|
17
|
+
cache?: string;
|
|
18
|
+
public?: string;
|
|
19
|
+
debug?: boolean;
|
|
20
|
+
pagePatterns?: string[];
|
|
21
|
+
markdown?: MarkdownOptions;
|
|
22
|
+
plugins?: PluginConfig[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Vuepress app config for dev
|
|
26
|
+
*/
|
|
27
|
+
export interface AppConfigDev {
|
|
28
|
+
host?: string;
|
|
29
|
+
port?: number;
|
|
30
|
+
open?: boolean;
|
|
31
|
+
templateDev?: string;
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Vuepress app config for build
|
|
35
|
+
*/
|
|
36
|
+
export interface AppConfigBuild {
|
|
37
|
+
shouldPreload?: ((file: string, type: string) => boolean) | boolean;
|
|
38
|
+
shouldPrefetch?: ((file: string, type: string) => boolean) | boolean;
|
|
39
|
+
templateBuild?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Vuepress app options
|
|
43
|
+
*/
|
|
44
|
+
export declare type AppOptions<T extends ThemeConfig = ThemeConfig, U extends BundlerConfig = BundlerConfig> = Required<AppConfig<T, U>>;
|
package/lib/types/page.d.ts
CHANGED
|
@@ -3,11 +3,11 @@ import type { PageData, PageFrontmatter } from '@vuepress/shared';
|
|
|
3
3
|
/**
|
|
4
4
|
* Vuepress Page
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export declare type Page<ExtraPageData extends Record<any, any> = Record<never, never>, ExtraPageFields extends Record<any, any> = Record<never, never>> = PageData & ExtraPageFields & {
|
|
7
7
|
/**
|
|
8
8
|
* Data of the page, which will be available in client code
|
|
9
9
|
*/
|
|
10
|
-
data:
|
|
10
|
+
data: PageData<ExtraPageData>;
|
|
11
11
|
/**
|
|
12
12
|
* Raw Content of the page
|
|
13
13
|
*/
|
|
@@ -56,6 +56,12 @@ export interface Page<T extends PageData = PageData> extends PageData {
|
|
|
56
56
|
* If the page does not have a permalink, it would be `null`
|
|
57
57
|
*/
|
|
58
58
|
permalink: string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Custom data to be attached to the page route record of vue-router
|
|
61
|
+
*
|
|
62
|
+
* @see https://next.router.vuejs.org/api/#meta
|
|
63
|
+
*/
|
|
64
|
+
routeMeta: Record<string, unknown>;
|
|
59
65
|
/**
|
|
60
66
|
* Slug of the page
|
|
61
67
|
*/
|
|
@@ -108,7 +114,7 @@ export interface Page<T extends PageData = PageData> extends PageData {
|
|
|
108
114
|
* Rendered html file path relative to dest directory
|
|
109
115
|
*/
|
|
110
116
|
htmlFilePathRelative: string;
|
|
111
|
-
}
|
|
117
|
+
};
|
|
112
118
|
/**
|
|
113
119
|
* Options to create vuepress page
|
|
114
120
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Markdown } from '@vuepress/markdown';
|
|
1
|
+
import type { Markdown, MarkdownOptions } from '@vuepress/markdown';
|
|
2
2
|
import type { App } from '../app';
|
|
3
3
|
import type { Page, PageOptions } from '../page';
|
|
4
4
|
declare type PromiseOrNot<T> = Promise<T> | T;
|
|
@@ -11,11 +11,9 @@ export declare type Hook<Exposed, Normalized = Exposed, Result = Normalized exte
|
|
|
11
11
|
result: Result;
|
|
12
12
|
};
|
|
13
13
|
export declare type LifeCycleHook<T extends unknown[] = []> = Hook<(app: App, ...args: T) => PromiseOrNot<void>>;
|
|
14
|
+
export declare type ExtendsHook<T> = Hook<(extendable: T, app: App) => PromiseOrNot<void>>;
|
|
14
15
|
export declare type ClientFilesHook = Hook<string | string[] | ((app: App) => PromiseOrNot<string | string[]>), (app: App) => Promise<string[]>>;
|
|
15
16
|
export declare type ReturnObjectHook = Hook<Record<string, any> | ((app: App) => PromiseOrNot<Record<string, any>>), (app: App) => Promise<Record<string, any>>>;
|
|
16
|
-
export declare type ExtendsMarkdownHook = Hook<(md: Markdown, app: App) => PromiseOrNot<void>>;
|
|
17
|
-
export declare type ExtendsPageOptionsHook = Hook<(options: PageOptions, app: App) => PromiseOrNot<PageOptions>>;
|
|
18
|
-
export declare type ExtendsPageDataHook = Hook<(page: Omit<Page, 'data'>, app: App) => PromiseOrNot<Record<string, any>>>;
|
|
19
17
|
/**
|
|
20
18
|
* List of hooks
|
|
21
19
|
*/
|
|
@@ -24,9 +22,10 @@ export interface Hooks {
|
|
|
24
22
|
onPrepared: LifeCycleHook;
|
|
25
23
|
onWatched: LifeCycleHook<[watchers: Closable[], restart: () => Promise<void>]>;
|
|
26
24
|
onGenerated: LifeCycleHook;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
extendsMarkdownOptions: ExtendsHook<MarkdownOptions>;
|
|
26
|
+
extendsMarkdown: ExtendsHook<Markdown>;
|
|
27
|
+
extendsPageOptions: ExtendsHook<PageOptions>;
|
|
28
|
+
extendsPage: ExtendsHook<Page>;
|
|
30
29
|
clientAppEnhanceFiles: ClientFilesHook;
|
|
31
30
|
clientAppRootComponentFiles: ClientFilesHook;
|
|
32
31
|
clientAppSetupFiles: ClientFilesHook;
|
package/lib/types/theme.d.ts
CHANGED
|
@@ -17,10 +17,30 @@ export declare type ThemeFunction<T extends ThemeConfig = ThemeConfig> = PluginF
|
|
|
17
17
|
* Vuepress theme object
|
|
18
18
|
*/
|
|
19
19
|
export interface ThemeObject extends PluginObject {
|
|
20
|
+
/**
|
|
21
|
+
* Theme plugin should never be multiple
|
|
22
|
+
*/
|
|
20
23
|
multiple?: false;
|
|
24
|
+
/**
|
|
25
|
+
* Extended parent theme
|
|
26
|
+
*/
|
|
21
27
|
extends?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Specify the layouts directory or components map
|
|
30
|
+
*/
|
|
22
31
|
layouts?: string | Record<string, string>;
|
|
32
|
+
/**
|
|
33
|
+
* Allow using plugins in theme
|
|
34
|
+
*/
|
|
23
35
|
plugins?: PluginConfig[];
|
|
36
|
+
/**
|
|
37
|
+
* Allow overriding default templateBuild
|
|
38
|
+
*/
|
|
39
|
+
templateBuild?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Allow overriding default templateDev
|
|
42
|
+
*/
|
|
43
|
+
templateDev?: string;
|
|
24
44
|
}
|
|
25
45
|
/**
|
|
26
46
|
* Theme config to be used in user config file
|
|
@@ -44,4 +64,12 @@ export interface ThemeInfo {
|
|
|
44
64
|
* Plugins, including theme itself and plugins used by theme
|
|
45
65
|
*/
|
|
46
66
|
plugins: PluginObject[];
|
|
67
|
+
/**
|
|
68
|
+
* Default build template
|
|
69
|
+
*/
|
|
70
|
+
templateBuild?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Default dev template
|
|
73
|
+
*/
|
|
74
|
+
templateDev?: string;
|
|
47
75
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.33",
|
|
4
4
|
"description": "Core package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"clean": "rimraf lib *.tsbuildinfo"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@vuepress/client": "2.0.0-beta.
|
|
30
|
-
"@vuepress/markdown": "2.0.0-beta.
|
|
31
|
-
"@vuepress/shared": "2.0.0-beta.
|
|
32
|
-
"@vuepress/utils": "2.0.0-beta.
|
|
29
|
+
"@vuepress/client": "2.0.0-beta.33",
|
|
30
|
+
"@vuepress/markdown": "2.0.0-beta.33",
|
|
31
|
+
"@vuepress/shared": "2.0.0-beta.33",
|
|
32
|
+
"@vuepress/utils": "2.0.0-beta.33",
|
|
33
33
|
"gray-matter": "^4.0.3",
|
|
34
34
|
"toml": "^3.0.0"
|
|
35
35
|
},
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "0934a5d6685922e0dc6391622b00a3b89140492c"
|
|
40
40
|
}
|
package/lib/app/createAppEnv.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAppEnv = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Create environment flags for vuepress app
|
|
6
|
-
*/
|
|
7
|
-
const createAppEnv = (options, isBuild) => ({
|
|
8
|
-
isBuild,
|
|
9
|
-
isDev: !isBuild,
|
|
10
|
-
isDebug: options.debug,
|
|
11
|
-
});
|
|
12
|
-
exports.createAppEnv = createAppEnv;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { AppConfig, AppOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Create app options with default values
|
|
4
|
-
*/
|
|
5
|
-
export declare const createAppOptions: ({ base, lang, title, description, head, locales, theme, themeConfig, bundler, bundlerConfig, source, dest, temp, cache, public: publicDir, markdown, host, port, debug, open, pagePatterns, templateDev, templateSSR, shouldPreload, shouldPrefetch, plugins, }: AppConfig) => AppOptions;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAppVersion = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Create version of vuepress app
|
|
6
|
-
*/
|
|
7
|
-
const createAppVersion = () => {
|
|
8
|
-
return require('../../package.json').version;
|
|
9
|
-
};
|
|
10
|
-
exports.createAppVersion = createAppVersion;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { App, Plugin, PluginObject, PluginOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve a plugin according to name / path / module and config
|
|
4
|
-
*/
|
|
5
|
-
export declare const resolvePlugin: <T extends PluginOptions = PluginOptions, U extends PluginObject = PluginObject>(app: App, plugin: string | Plugin<T, U>, config?: Partial<T>) => U;
|
package/lib/app/resolveTheme.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveTheme = void 0;
|
|
4
|
-
const shared_1 = require("@vuepress/shared");
|
|
5
|
-
const utils_1 = require("@vuepress/utils");
|
|
6
|
-
const resolvePlugin_1 = require("./resolvePlugin");
|
|
7
|
-
/**
|
|
8
|
-
* Resolve a theme according to the theme name
|
|
9
|
-
*/
|
|
10
|
-
const resolveTheme = (app, themeName) => {
|
|
11
|
-
// resolve theme entry according to theme name
|
|
12
|
-
const themeEntry = (0, utils_1.requireResolve)(utils_1.path.isAbsolute(themeName)
|
|
13
|
-
? themeName
|
|
14
|
-
: (0, shared_1.normalizePackageName)(themeName, 'vuepress', 'theme'));
|
|
15
|
-
if (themeEntry === null) {
|
|
16
|
-
throw utils_1.logger.createError(`theme is not found: ${utils_1.chalk.magenta(themeName)}`);
|
|
17
|
-
}
|
|
18
|
-
// resolve theme from theme entry
|
|
19
|
-
const theme = (0, resolvePlugin_1.resolvePlugin)(app, themeEntry, app.options.themeConfig);
|
|
20
|
-
return theme;
|
|
21
|
-
};
|
|
22
|
-
exports.resolveTheme = resolveTheme;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageData = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Resolve page data
|
|
6
|
-
*/
|
|
7
|
-
const resolvePageData = async ({ app, page, }) => {
|
|
8
|
-
const { key, path, title, lang, frontmatter, excerpt, headers } = page;
|
|
9
|
-
const data = {
|
|
10
|
-
key,
|
|
11
|
-
path,
|
|
12
|
-
title,
|
|
13
|
-
lang,
|
|
14
|
-
frontmatter,
|
|
15
|
-
excerpt,
|
|
16
|
-
headers,
|
|
17
|
-
};
|
|
18
|
-
// plugin hook: extendsPageData
|
|
19
|
-
const extendsPageData = await app.pluginApi.hooks.extendsPageData.process(page, app);
|
|
20
|
-
extendsPageData.forEach((item) => Object.assign(data, item));
|
|
21
|
-
return data;
|
|
22
|
-
};
|
|
23
|
-
exports.resolvePageData = resolvePageData;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageOptions = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Render page content and extract related info
|
|
6
|
-
*/
|
|
7
|
-
const resolvePageOptions = async ({ app, optionsRaw, }) => {
|
|
8
|
-
// avoid mutating the original options object provided by user
|
|
9
|
-
const options = { ...optionsRaw };
|
|
10
|
-
// plugin hook: extendsPageOptions
|
|
11
|
-
const extendsPageOptions = await app.pluginApi.hooks.extendsPageOptions.process(options, app);
|
|
12
|
-
extendsPageOptions.forEach((item) => Object.assign(options, item));
|
|
13
|
-
return options;
|
|
14
|
-
};
|
|
15
|
-
exports.resolvePageOptions = resolvePageOptions;
|