@vuepress/core 2.0.0-beta.48 → 2.0.0-beta.50-pre
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/package.json +30 -13
- package/lib/app/appInit.d.ts +0 -7
- package/lib/app/appInit.js +0 -27
- package/lib/app/appPrepare.d.ts +0 -10
- package/lib/app/appPrepare.js +0 -39
- package/lib/app/appUse.d.ts +0 -2
- package/lib/app/appUse.js +0 -28
- package/lib/app/createBaseApp.d.ts +0 -5
- package/lib/app/createBaseApp.js +0 -46
- package/lib/app/createBuildApp.d.ts +0 -5
- package/lib/app/createBuildApp.js +0 -13
- package/lib/app/createDevApp.d.ts +0 -5
- package/lib/app/createDevApp.js +0 -13
- package/lib/app/index.d.ts +0 -17
- package/lib/app/index.js +0 -33
- package/lib/app/prepare/index.d.ts +0 -8
- package/lib/app/prepare/index.js +0 -24
- package/lib/app/prepare/prepareClientConfigs.d.ts +0 -5
- package/lib/app/prepare/prepareClientConfigs.js +0 -22
- package/lib/app/prepare/prepareLayoutComponents.d.ts +0 -5
- package/lib/app/prepare/prepareLayoutComponents.js +0 -20
- package/lib/app/prepare/preparePageComponent.d.ts +0 -5
- package/lib/app/prepare/preparePageComponent.js +0 -16
- package/lib/app/prepare/preparePageData.d.ts +0 -5
- package/lib/app/prepare/preparePageData.js +0 -31
- package/lib/app/prepare/preparePagesComponents.d.ts +0 -5
- package/lib/app/prepare/preparePagesComponents.js +0 -24
- package/lib/app/prepare/preparePagesData.d.ts +0 -5
- package/lib/app/prepare/preparePagesData.js +0 -20
- package/lib/app/prepare/preparePagesRoutes.d.ts +0 -5
- package/lib/app/prepare/preparePagesRoutes.js +0 -48
- package/lib/app/prepare/prepareSiteData.d.ts +0 -5
- package/lib/app/prepare/prepareSiteData.js +0 -31
- package/lib/app/resolveAppDir.d.ts +0 -9
- package/lib/app/resolveAppDir.js +0 -32
- package/lib/app/resolveAppEnv.d.ts +0 -5
- package/lib/app/resolveAppEnv.js +0 -12
- package/lib/app/resolveAppMarkdown.d.ts +0 -6
- package/lib/app/resolveAppMarkdown.js +0 -16
- package/lib/app/resolveAppOptions.d.ts +0 -5
- package/lib/app/resolveAppOptions.js +0 -45
- package/lib/app/resolveAppPages.d.ts +0 -5
- package/lib/app/resolveAppPages.js +0 -31
- package/lib/app/resolveAppSiteData.d.ts +0 -7
- package/lib/app/resolveAppSiteData.js +0 -17
- package/lib/app/resolveAppVersion.d.ts +0 -4
- package/lib/app/resolveAppVersion.js +0 -10
- package/lib/app/resolveAppWriteTemp.d.ts +0 -5
- package/lib/app/resolveAppWriteTemp.js +0 -21
- package/lib/app/resolvePluginObject.d.ts +0 -5
- package/lib/app/resolvePluginObject.js +0 -9
- package/lib/app/resolveThemeInfo.d.ts +0 -5
- package/lib/app/resolveThemeInfo.js +0 -31
- package/lib/app/resolveThemeLayouts.d.ts +0 -5
- package/lib/app/resolveThemeLayouts.js +0 -25
- package/lib/app/setupAppThemeAndPlugins.d.ts +0 -5
- package/lib/app/setupAppThemeAndPlugins.js +0 -21
- package/lib/index.d.ts +0 -4
- package/lib/index.js +0 -20
- package/lib/page/createPage.d.ts +0 -2
- package/lib/page/createPage.js +0 -135
- package/lib/page/index.d.ts +0 -18
- package/lib/page/index.js +0 -34
- package/lib/page/inferPagePath.d.ts +0 -11
- package/lib/page/inferPagePath.js +0 -27
- package/lib/page/renderPageContent.d.ts +0 -19
- package/lib/page/renderPageContent.js +0 -26
- package/lib/page/renderPageExcerpt.d.ts +0 -11
- package/lib/page/renderPageExcerpt.js +0 -17
- package/lib/page/resolvePageComponentInfo.d.ts +0 -13
- package/lib/page/resolvePageComponentInfo.js +0 -19
- package/lib/page/resolvePageContent.d.ts +0 -11
- package/lib/page/resolvePageContent.js +0 -30
- package/lib/page/resolvePageDataInfo.d.ts +0 -13
- package/lib/page/resolvePageDataInfo.js +0 -18
- package/lib/page/resolvePageDate.d.ts +0 -10
- package/lib/page/resolvePageDate.js +0 -45
- package/lib/page/resolvePageFileContent.d.ts +0 -8
- package/lib/page/resolvePageFileContent.js +0 -23
- package/lib/page/resolvePageFilePath.d.ts +0 -11
- package/lib/page/resolvePageFilePath.js +0 -24
- package/lib/page/resolvePageFrontmatter.d.ts +0 -8
- package/lib/page/resolvePageFrontmatter.js +0 -12
- package/lib/page/resolvePageHtmlInfo.d.ts +0 -11
- package/lib/page/resolvePageHtmlInfo.js +0 -18
- package/lib/page/resolvePageKey.d.ts +0 -6
- package/lib/page/resolvePageKey.js +0 -9
- package/lib/page/resolvePageLang.d.ts +0 -9
- package/lib/page/resolvePageLang.js +0 -14
- package/lib/page/resolvePagePath.d.ts +0 -9
- package/lib/page/resolvePagePath.js +0 -19
- package/lib/page/resolvePagePermalink.d.ts +0 -12
- package/lib/page/resolvePagePermalink.js +0 -41
- package/lib/page/resolvePageRouteMeta.d.ts +0 -7
- package/lib/page/resolvePageRouteMeta.js +0 -8
- package/lib/page/resolvePageSlug.d.ts +0 -6
- package/lib/page/resolvePageSlug.js +0 -17
- package/lib/pluginApi/createHookQueue.d.ts +0 -5
- package/lib/pluginApi/createHookQueue.js +0 -42
- package/lib/pluginApi/createPluginApi.d.ts +0 -2
- package/lib/pluginApi/createPluginApi.js +0 -16
- package/lib/pluginApi/createPluginApiHooks.d.ts +0 -2
- package/lib/pluginApi/createPluginApiHooks.js +0 -23
- package/lib/pluginApi/createPluginApiRegisterHooks.d.ts +0 -2
- package/lib/pluginApi/createPluginApiRegisterHooks.js +0 -42
- package/lib/pluginApi/index.d.ts +0 -6
- package/lib/pluginApi/index.js +0 -22
- package/lib/pluginApi/normalizeClientConfigFileHook.d.ts +0 -5
- package/lib/pluginApi/normalizeClientConfigFileHook.js +0 -19
- package/lib/pluginApi/normalizeReturnObjectHook.d.ts +0 -5
- package/lib/pluginApi/normalizeReturnObjectHook.js +0 -9
- package/lib/types/app/app.d.ts +0 -98
- package/lib/types/app/app.js +0 -2
- package/lib/types/app/index.d.ts +0 -3
- package/lib/types/app/index.js +0 -19
- package/lib/types/app/options.d.ts +0 -84
- package/lib/types/app/options.js +0 -2
- package/lib/types/app/utils.d.ts +0 -36
- package/lib/types/app/utils.js +0 -2
- package/lib/types/bundler.d.ts +0 -13
- package/lib/types/bundler.js +0 -2
- package/lib/types/index.d.ts +0 -8
- package/lib/types/index.js +0 -22
- package/lib/types/page.d.ts +0 -144
- package/lib/types/page.js +0 -2
- package/lib/types/plugin.d.ts +0 -29
- package/lib/types/plugin.js +0 -2
- package/lib/types/pluginApi/hooks.d.ts +0 -72
- package/lib/types/pluginApi/hooks.js +0 -2
- package/lib/types/pluginApi/index.d.ts +0 -2
- package/lib/types/pluginApi/index.js +0 -18
- package/lib/types/pluginApi/pluginApi.d.ts +0 -23
- package/lib/types/pluginApi/pluginApi.js +0 -2
- package/lib/types/theme.d.ts +0 -61
- package/lib/types/theme.js +0 -2
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renderPageContent = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Render page content and extract related info
|
|
6
|
-
*/
|
|
7
|
-
const renderPageContent = async ({ app, content, frontmatter, filePath, filePathRelative, }) => {
|
|
8
|
-
const markdownEnv = {
|
|
9
|
-
base: app.options.base,
|
|
10
|
-
filePath,
|
|
11
|
-
filePathRelative,
|
|
12
|
-
frontmatter,
|
|
13
|
-
};
|
|
14
|
-
const contentRendered = app.markdown.render(content, markdownEnv);
|
|
15
|
-
/* istanbul ignore next */
|
|
16
|
-
const { headers = [], hoistedTags = [], importedFiles = [], links = [], title = '', } = markdownEnv;
|
|
17
|
-
return {
|
|
18
|
-
contentRendered,
|
|
19
|
-
deps: importedFiles,
|
|
20
|
-
headers,
|
|
21
|
-
hoistedTags,
|
|
22
|
-
links,
|
|
23
|
-
title,
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
exports.renderPageContent = renderPageContent;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { App, PageFrontmatter } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Render page excerpt from raw excerpt
|
|
4
|
-
*/
|
|
5
|
-
export declare const renderPageExcerpt: ({ app, excerptRaw, frontmatter, filePath, filePathRelative, }: {
|
|
6
|
-
app: App;
|
|
7
|
-
excerptRaw: string;
|
|
8
|
-
frontmatter: PageFrontmatter;
|
|
9
|
-
filePath: string | null;
|
|
10
|
-
filePathRelative: string | null;
|
|
11
|
-
}) => string;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renderPageExcerpt = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Render page excerpt from raw excerpt
|
|
6
|
-
*/
|
|
7
|
-
const renderPageExcerpt = ({ app, excerptRaw, frontmatter, filePath, filePathRelative, }) => {
|
|
8
|
-
const markdownEnv = {
|
|
9
|
-
base: app.options.base,
|
|
10
|
-
filePath,
|
|
11
|
-
filePathRelative,
|
|
12
|
-
frontmatter,
|
|
13
|
-
};
|
|
14
|
-
const renderedExcerpt = app.markdown.render(excerptRaw, markdownEnv);
|
|
15
|
-
return renderedExcerpt;
|
|
16
|
-
};
|
|
17
|
-
exports.renderPageExcerpt = renderPageExcerpt;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { App } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve page component and related info
|
|
4
|
-
*/
|
|
5
|
-
export declare const resolvePageComponentInfo: ({ app, htmlFilePathRelative, key, }: {
|
|
6
|
-
app: App;
|
|
7
|
-
htmlFilePathRelative: string;
|
|
8
|
-
key: string;
|
|
9
|
-
}) => Promise<{
|
|
10
|
-
componentFilePath: string;
|
|
11
|
-
componentFilePathRelative: string;
|
|
12
|
-
componentFileChunkName: string;
|
|
13
|
-
}>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageComponentInfo = void 0;
|
|
4
|
-
const utils_1 = require("@vuepress/utils");
|
|
5
|
-
/**
|
|
6
|
-
* Resolve page component and related info
|
|
7
|
-
*/
|
|
8
|
-
const resolvePageComponentInfo = async ({ app, htmlFilePathRelative, key, }) => {
|
|
9
|
-
// resolve component file path
|
|
10
|
-
const componentFilePathRelative = utils_1.path.join('pages', `${htmlFilePathRelative}.vue`);
|
|
11
|
-
const componentFilePath = app.dir.temp(componentFilePathRelative);
|
|
12
|
-
const componentFileChunkName = key;
|
|
13
|
-
return {
|
|
14
|
-
componentFilePath,
|
|
15
|
-
componentFilePathRelative,
|
|
16
|
-
componentFileChunkName,
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
exports.resolvePageComponentInfo = resolvePageComponentInfo;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { PageFrontmatter } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve page content and raw frontmatter & excerpt
|
|
4
|
-
*/
|
|
5
|
-
export declare const resolvePageContent: ({ contentRaw, }: {
|
|
6
|
-
contentRaw: string;
|
|
7
|
-
}) => {
|
|
8
|
-
content: string;
|
|
9
|
-
frontmatterRaw: PageFrontmatter;
|
|
10
|
-
excerptRaw: string;
|
|
11
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageContent = void 0;
|
|
4
|
-
const matter = require("gray-matter");
|
|
5
|
-
const toml = require("toml");
|
|
6
|
-
/**
|
|
7
|
-
* Resolve page content and raw frontmatter & excerpt
|
|
8
|
-
*/
|
|
9
|
-
const resolvePageContent = ({ contentRaw, }) => {
|
|
10
|
-
if (!contentRaw) {
|
|
11
|
-
return {
|
|
12
|
-
content: '',
|
|
13
|
-
frontmatterRaw: {},
|
|
14
|
-
excerptRaw: '',
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
/* istanbul ignore next */
|
|
18
|
-
const { data, content, excerpt = '', } = matter(contentRaw, {
|
|
19
|
-
excerpt_separator: '<!-- more -->',
|
|
20
|
-
engines: {
|
|
21
|
-
toml: toml.parse.bind(toml),
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
return {
|
|
25
|
-
content,
|
|
26
|
-
frontmatterRaw: data,
|
|
27
|
-
excerptRaw: excerpt,
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
exports.resolvePageContent = resolvePageContent;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { App } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve page data file path
|
|
4
|
-
*/
|
|
5
|
-
export declare const resolvePageDataInfo: ({ app, htmlFilePathRelative, key, }: {
|
|
6
|
-
app: App;
|
|
7
|
-
htmlFilePathRelative: string;
|
|
8
|
-
key: string;
|
|
9
|
-
}) => {
|
|
10
|
-
dataFilePath: string;
|
|
11
|
-
dataFilePathRelative: string;
|
|
12
|
-
dataFileChunkName: string;
|
|
13
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageDataInfo = void 0;
|
|
4
|
-
const utils_1 = require("@vuepress/utils");
|
|
5
|
-
/**
|
|
6
|
-
* Resolve page data file path
|
|
7
|
-
*/
|
|
8
|
-
const resolvePageDataInfo = ({ app, htmlFilePathRelative, key, }) => {
|
|
9
|
-
const dataFilePathRelative = utils_1.path.join('pages', `${htmlFilePathRelative}.js`);
|
|
10
|
-
const dataFilePath = app.dir.temp(dataFilePathRelative);
|
|
11
|
-
const dataFileChunkName = key;
|
|
12
|
-
return {
|
|
13
|
-
dataFilePath,
|
|
14
|
-
dataFilePathRelative,
|
|
15
|
-
dataFileChunkName,
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
exports.resolvePageDataInfo = resolvePageDataInfo;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { PageFrontmatter } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve page date according to frontmatter or file path
|
|
4
|
-
*
|
|
5
|
-
* It will be resolved as 'yyyy-MM-dd' format
|
|
6
|
-
*/
|
|
7
|
-
export declare const resolvePageDate: ({ frontmatter, filePathRelative, }: {
|
|
8
|
-
frontmatter: PageFrontmatter;
|
|
9
|
-
filePathRelative: string | null;
|
|
10
|
-
}) => string;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageDate = void 0;
|
|
4
|
-
const shared_1 = require("@vuepress/shared");
|
|
5
|
-
const utils_1 = require("@vuepress/utils");
|
|
6
|
-
const FILENAME_DATE_RE = /^(\d{4})-(\d{1,2})(?:-(\d{1,2}))?-(.*)$/;
|
|
7
|
-
const DIRNAME_DATE_RE = /(\d{4})\/(\d{1,2})(?:\/(\d{1,2}))?(\/|$)/;
|
|
8
|
-
const DEFAULT_DATE = '0000-00-00';
|
|
9
|
-
/**
|
|
10
|
-
* Resolve page date according to frontmatter or file path
|
|
11
|
-
*
|
|
12
|
-
* It will be resolved as 'yyyy-MM-dd' format
|
|
13
|
-
*/
|
|
14
|
-
const resolvePageDate = ({ frontmatter, filePathRelative, }) => {
|
|
15
|
-
// `frontmatter.date` could be parsed as UTC Date directly
|
|
16
|
-
if (frontmatter.date instanceof Date) {
|
|
17
|
-
return (0, shared_1.formatDateString)([
|
|
18
|
-
frontmatter.date.getUTCFullYear(),
|
|
19
|
-
frontmatter.date.getUTCMonth() + 1,
|
|
20
|
-
frontmatter.date.getUTCDate(),
|
|
21
|
-
].join('-'), DEFAULT_DATE);
|
|
22
|
-
}
|
|
23
|
-
if ((0, shared_1.isString)(frontmatter.date)) {
|
|
24
|
-
return (0, shared_1.formatDateString)(frontmatter.date, DEFAULT_DATE);
|
|
25
|
-
}
|
|
26
|
-
if (filePathRelative === null) {
|
|
27
|
-
return DEFAULT_DATE;
|
|
28
|
-
}
|
|
29
|
-
const filename = utils_1.path.parse(filePathRelative).name;
|
|
30
|
-
if (filename) {
|
|
31
|
-
const matches = filename.match(FILENAME_DATE_RE);
|
|
32
|
-
if (matches) {
|
|
33
|
-
return (0, shared_1.formatDateString)(`${matches[1]}-${matches[2]}-${matches[3] ?? '01'}`, DEFAULT_DATE);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const dirname = utils_1.path.dirname(filePathRelative);
|
|
37
|
-
if (dirname !== '.') {
|
|
38
|
-
const matches = dirname.match(DIRNAME_DATE_RE);
|
|
39
|
-
if (matches) {
|
|
40
|
-
return (0, shared_1.formatDateString)(`${matches[1]}-${matches[2]}-${matches[3] ?? '01'}`, DEFAULT_DATE);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return DEFAULT_DATE;
|
|
44
|
-
};
|
|
45
|
-
exports.resolvePageDate = resolvePageDate;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { PageOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve page file content according to filePath or options content
|
|
4
|
-
*/
|
|
5
|
-
export declare const resolvePageFileContent: ({ filePath, options, }: {
|
|
6
|
-
filePath: string | null;
|
|
7
|
-
options: PageOptions;
|
|
8
|
-
}) => Promise<string>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageFileContent = void 0;
|
|
4
|
-
const utils_1 = require("@vuepress/utils");
|
|
5
|
-
const log = (0, utils_1.debug)('vuepress:core/page');
|
|
6
|
-
/**
|
|
7
|
-
* Resolve page file content according to filePath or options content
|
|
8
|
-
*/
|
|
9
|
-
const resolvePageFileContent = async ({ filePath, options, }) => {
|
|
10
|
-
if (filePath) {
|
|
11
|
-
try {
|
|
12
|
-
// read page content from file
|
|
13
|
-
const content = await utils_1.fs.readFile(filePath, 'utf-8');
|
|
14
|
-
return content;
|
|
15
|
-
}
|
|
16
|
-
catch (e) {
|
|
17
|
-
log(e instanceof Error ? e.message : e);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
// load raw content from options
|
|
21
|
-
return options.content ?? '';
|
|
22
|
-
};
|
|
23
|
-
exports.resolvePageFileContent = resolvePageFileContent;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { App, PageOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve absolute and relative path of page file
|
|
4
|
-
*/
|
|
5
|
-
export declare const resolvePageFilePath: ({ app, options, }: {
|
|
6
|
-
app: App;
|
|
7
|
-
options: PageOptions;
|
|
8
|
-
}) => {
|
|
9
|
-
filePath: string | null;
|
|
10
|
-
filePathRelative: string | null;
|
|
11
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageFilePath = void 0;
|
|
4
|
-
const utils_1 = require("@vuepress/utils");
|
|
5
|
-
/**
|
|
6
|
-
* Resolve absolute and relative path of page file
|
|
7
|
-
*/
|
|
8
|
-
const resolvePageFilePath = ({ app, options, }) => {
|
|
9
|
-
// empty file path
|
|
10
|
-
if (!options.filePath) {
|
|
11
|
-
return {
|
|
12
|
-
filePath: null,
|
|
13
|
-
filePathRelative: null,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
if (!utils_1.path.isAbsolute(options.filePath)) {
|
|
17
|
-
throw utils_1.logger.createError(`filePath is not absolute file path: ${options.filePath}}`);
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
filePath: options.filePath,
|
|
21
|
-
filePathRelative: utils_1.path.relative(app.dir.source(), options.filePath),
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
exports.resolvePageFilePath = resolvePageFilePath;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { PageFrontmatter, PageOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve page frontmatter from user frontmatter and options frontmatter
|
|
4
|
-
*/
|
|
5
|
-
export declare const resolvePageFrontmatter: ({ frontmatterRaw, options, }: {
|
|
6
|
-
frontmatterRaw: PageFrontmatter;
|
|
7
|
-
options: PageOptions;
|
|
8
|
-
}) => PageFrontmatter;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageFrontmatter = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Resolve page frontmatter from user frontmatter and options frontmatter
|
|
6
|
-
*/
|
|
7
|
-
const resolvePageFrontmatter = ({ frontmatterRaw, options, }) => ({
|
|
8
|
-
// raw frontmatter take priority over options frontmatter
|
|
9
|
-
...options.frontmatter,
|
|
10
|
-
...frontmatterRaw,
|
|
11
|
-
});
|
|
12
|
-
exports.resolvePageFrontmatter = resolvePageFrontmatter;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { App } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve page rendered html file path
|
|
4
|
-
*/
|
|
5
|
-
export declare const resolvePageHtmlInfo: ({ app, path: pagePath, }: {
|
|
6
|
-
app: App;
|
|
7
|
-
path: string;
|
|
8
|
-
}) => {
|
|
9
|
-
htmlFilePath: string;
|
|
10
|
-
htmlFilePathRelative: string;
|
|
11
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageHtmlInfo = void 0;
|
|
4
|
-
const shared_1 = require("@vuepress/shared");
|
|
5
|
-
/**
|
|
6
|
-
* Resolve page rendered html file path
|
|
7
|
-
*/
|
|
8
|
-
const resolvePageHtmlInfo = ({ app, path: pagePath, }) => {
|
|
9
|
-
// /foo.html -> foo.html
|
|
10
|
-
// /foo/ -> foo/index.html
|
|
11
|
-
const htmlFilePathRelative = (0, shared_1.removeLeadingSlash)(decodeURI(pagePath.replace(/\/$/, '/index.html')));
|
|
12
|
-
const htmlFilePath = app.dir.dest(htmlFilePathRelative);
|
|
13
|
-
return {
|
|
14
|
-
htmlFilePath,
|
|
15
|
-
htmlFilePathRelative,
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
exports.resolvePageHtmlInfo = resolvePageHtmlInfo;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageKey = void 0;
|
|
4
|
-
const utils_1 = require("@vuepress/utils");
|
|
5
|
-
/**
|
|
6
|
-
* Resolve page key to identify the page
|
|
7
|
-
*/
|
|
8
|
-
const resolvePageKey = ({ path }) => `v-${(0, utils_1.hash)(path)}`;
|
|
9
|
-
exports.resolvePageKey = resolvePageKey;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageLang = void 0;
|
|
4
|
-
const shared_1 = require("@vuepress/shared");
|
|
5
|
-
/**
|
|
6
|
-
* Resolve language of page
|
|
7
|
-
*/
|
|
8
|
-
const resolvePageLang = ({ app, frontmatter, pathLocale, }) => {
|
|
9
|
-
if ((0, shared_1.isString)(frontmatter.lang) && frontmatter.lang) {
|
|
10
|
-
return frontmatter.lang;
|
|
11
|
-
}
|
|
12
|
-
return app.siteData.locales[pathLocale]?.lang ?? app.siteData.lang;
|
|
13
|
-
};
|
|
14
|
-
exports.resolvePageLang = resolvePageLang;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { PageOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve the final route path of a page
|
|
4
|
-
*/
|
|
5
|
-
export declare const resolvePagePath: ({ permalink, pathInferred, options, }: {
|
|
6
|
-
permalink: string | null;
|
|
7
|
-
pathInferred: string | null;
|
|
8
|
-
options: PageOptions;
|
|
9
|
-
}) => string;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePagePath = void 0;
|
|
4
|
-
const shared_1 = require("@vuepress/shared");
|
|
5
|
-
const utils_1 = require("@vuepress/utils");
|
|
6
|
-
/**
|
|
7
|
-
* Resolve the final route path of a page
|
|
8
|
-
*/
|
|
9
|
-
const resolvePagePath = ({ permalink, pathInferred, options, }) => {
|
|
10
|
-
let pagePath = options.path || permalink || pathInferred;
|
|
11
|
-
if (!pagePath) {
|
|
12
|
-
throw utils_1.logger.createError(`page path is empty, page options: ${JSON.stringify(options, null, 2)}`);
|
|
13
|
-
}
|
|
14
|
-
if (!pagePath.endsWith('.html')) {
|
|
15
|
-
pagePath = (0, shared_1.ensureEndingSlash)(pagePath);
|
|
16
|
-
}
|
|
17
|
-
return encodeURI(pagePath);
|
|
18
|
-
};
|
|
19
|
-
exports.resolvePagePath = resolvePagePath;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { App, PageFrontmatter } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve page permalink from frontmatter / options / pattern
|
|
4
|
-
*/
|
|
5
|
-
export declare const resolvePagePermalink: ({ app, frontmatter, slug, date, pathInferred, pathLocale, }: {
|
|
6
|
-
app: App;
|
|
7
|
-
frontmatter: PageFrontmatter;
|
|
8
|
-
slug: string;
|
|
9
|
-
date: string;
|
|
10
|
-
pathInferred: string | null;
|
|
11
|
-
pathLocale: string;
|
|
12
|
-
}) => string | null;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePagePermalink = void 0;
|
|
4
|
-
const shared_1 = require("@vuepress/shared");
|
|
5
|
-
const utils_1 = require("@vuepress/utils");
|
|
6
|
-
/**
|
|
7
|
-
* Resolve page permalink from frontmatter / options / pattern
|
|
8
|
-
*/
|
|
9
|
-
const resolvePagePermalink = ({ app, frontmatter, slug, date, pathInferred, pathLocale, }) => {
|
|
10
|
-
// use permalink in frontmatter directly
|
|
11
|
-
if ((0, shared_1.isString)(frontmatter.permalink)) {
|
|
12
|
-
return frontmatter.permalink;
|
|
13
|
-
}
|
|
14
|
-
// get permalink pattern
|
|
15
|
-
const permalinkPattern = getPermalinkPattern({ app, frontmatter });
|
|
16
|
-
if (permalinkPattern === null) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
// resolve permalink according to the pattern
|
|
20
|
-
const [year, month, day] = date.split('-');
|
|
21
|
-
const link = utils_1.path.join(pathLocale, permalinkPattern
|
|
22
|
-
.replace(/:year/, year)
|
|
23
|
-
.replace(/:month/, month)
|
|
24
|
-
.replace(/:day/, day)
|
|
25
|
-
.replace(/:slug/, slug)
|
|
26
|
-
.replace(/:raw/, pathInferred?.replace(/^\//, '') ?? ''));
|
|
27
|
-
return (0, shared_1.ensureLeadingSlash)(link);
|
|
28
|
-
};
|
|
29
|
-
exports.resolvePagePermalink = resolvePagePermalink;
|
|
30
|
-
/**
|
|
31
|
-
* Get permalink pattern from frontmatter or app options
|
|
32
|
-
*/
|
|
33
|
-
const getPermalinkPattern = ({ app, frontmatter, }) => {
|
|
34
|
-
if (frontmatter.permalinkPattern === null) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
if ((0, shared_1.isString)(frontmatter.permalinkPattern)) {
|
|
38
|
-
return frontmatter.permalinkPattern;
|
|
39
|
-
}
|
|
40
|
-
return app.options.permalinkPattern;
|
|
41
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
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, }) => frontmatter.routeMeta ?? {};
|
|
8
|
-
exports.resolvePageRouteMeta = resolvePageRouteMeta;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageSlug = void 0;
|
|
4
|
-
const utils_1 = require("@vuepress/utils");
|
|
5
|
-
const DATE_RE = /(\d{4}-\d{1,2}(-\d{1,2})?)-(.*)/;
|
|
6
|
-
/**
|
|
7
|
-
* Resolve page slug from filename
|
|
8
|
-
*/
|
|
9
|
-
const resolvePageSlug = ({ filePathRelative, }) => {
|
|
10
|
-
if (!filePathRelative) {
|
|
11
|
-
return '';
|
|
12
|
-
}
|
|
13
|
-
const filename = utils_1.path.parse(filePathRelative).name;
|
|
14
|
-
const match = filename.match(DATE_RE);
|
|
15
|
-
return match ? match[3] : filename;
|
|
16
|
-
};
|
|
17
|
-
exports.resolvePageSlug = resolvePageSlug;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createHookQueue = void 0;
|
|
4
|
-
const utils_1 = require("@vuepress/utils");
|
|
5
|
-
const log = (0, utils_1.debug)('vuepress:core/plugin-api');
|
|
6
|
-
/**
|
|
7
|
-
* Create hook queue for plugin system
|
|
8
|
-
*/
|
|
9
|
-
const createHookQueue = (name) => {
|
|
10
|
-
const items = [];
|
|
11
|
-
const hookQueue = {
|
|
12
|
-
name,
|
|
13
|
-
items,
|
|
14
|
-
add: (item) => {
|
|
15
|
-
items.push(item);
|
|
16
|
-
},
|
|
17
|
-
process: async (...args) => {
|
|
18
|
-
// store the results of all hook items
|
|
19
|
-
const results = [];
|
|
20
|
-
// process all hook items
|
|
21
|
-
for (const item of items) {
|
|
22
|
-
log(`process ${utils_1.chalk.magenta(name)} from ${utils_1.chalk.magenta(item.pluginName)}`);
|
|
23
|
-
try {
|
|
24
|
-
// process and get the result of the the hook item
|
|
25
|
-
// @ts-expect-error: the types could not be narrowed correctly
|
|
26
|
-
const result = (await item.hook(...args));
|
|
27
|
-
// push the result to results array
|
|
28
|
-
if (result !== undefined) {
|
|
29
|
-
results.push(result);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
catch (e) {
|
|
33
|
-
utils_1.logger.error(`error in hook ${utils_1.chalk.magenta(name)} from ${utils_1.chalk.magenta(item.pluginName)}`);
|
|
34
|
-
throw e;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return results;
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
return hookQueue;
|
|
41
|
-
};
|
|
42
|
-
exports.createHookQueue = createHookQueue;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPluginApi = void 0;
|
|
4
|
-
const createPluginApiHooks_1 = require("./createPluginApiHooks");
|
|
5
|
-
const createPluginApiRegisterHooks_1 = require("./createPluginApiRegisterHooks");
|
|
6
|
-
const createPluginApi = () => {
|
|
7
|
-
const plugins = [];
|
|
8
|
-
const hooks = (0, createPluginApiHooks_1.createPluginApiHooks)();
|
|
9
|
-
const registerHooks = (0, createPluginApiRegisterHooks_1.createPluginApiRegisterHooks)(plugins, hooks);
|
|
10
|
-
return {
|
|
11
|
-
plugins,
|
|
12
|
-
hooks,
|
|
13
|
-
registerHooks,
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
exports.createPluginApi = createPluginApi;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPluginApiHooks = void 0;
|
|
4
|
-
const createHookQueue_1 = require("./createHookQueue");
|
|
5
|
-
const createPluginApiHooks = () => ({
|
|
6
|
-
// life cycle hooks
|
|
7
|
-
onInitialized: (0, createHookQueue_1.createHookQueue)('onInitialized'),
|
|
8
|
-
onPrepared: (0, createHookQueue_1.createHookQueue)('onPrepared'),
|
|
9
|
-
onWatched: (0, createHookQueue_1.createHookQueue)('onWatched'),
|
|
10
|
-
onGenerated: (0, createHookQueue_1.createHookQueue)('onGenerated'),
|
|
11
|
-
// extends hooks
|
|
12
|
-
extendsMarkdownOptions: (0, createHookQueue_1.createHookQueue)('extendsMarkdownOptions'),
|
|
13
|
-
extendsMarkdown: (0, createHookQueue_1.createHookQueue)('extendsMarkdown'),
|
|
14
|
-
extendsPageOptions: (0, createHookQueue_1.createHookQueue)('extendsPageOptions'),
|
|
15
|
-
extendsPage: (0, createHookQueue_1.createHookQueue)('extendsPage'),
|
|
16
|
-
extendsBundlerOptions: (0, createHookQueue_1.createHookQueue)('extendsBundlerOptions'),
|
|
17
|
-
// client config file hooks
|
|
18
|
-
clientConfigFile: (0, createHookQueue_1.createHookQueue)('clientConfigFile'),
|
|
19
|
-
// bundler hooks
|
|
20
|
-
alias: (0, createHookQueue_1.createHookQueue)('alias'),
|
|
21
|
-
define: (0, createHookQueue_1.createHookQueue)('define'),
|
|
22
|
-
});
|
|
23
|
-
exports.createPluginApiHooks = createPluginApiHooks;
|