@vuepress/core 2.0.0-beta.4 → 2.0.0-beta.42
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 +6 -16
- package/lib/app/appPrepare.js +12 -15
- package/lib/app/appUse.d.ts +2 -2
- package/lib/app/appUse.js +17 -15
- package/lib/app/createBaseApp.d.ts +5 -0
- package/lib/app/createBaseApp.js +46 -0
- package/lib/app/createBuildApp.d.ts +5 -0
- package/lib/app/createBuildApp.js +13 -0
- package/lib/app/createDevApp.d.ts +5 -0
- package/lib/app/createDevApp.js +13 -0
- package/lib/app/index.d.ts +13 -12
- package/lib/app/index.js +18 -13
- package/lib/app/prepare/index.d.ts +1 -3
- package/lib/app/prepare/index.js +6 -4
- package/lib/app/prepare/prepareLayoutComponents.js +2 -2
- package/lib/app/prepare/preparePageComponent.js +6 -1
- package/lib/app/prepare/preparePageData.js +7 -11
- package/lib/app/prepare/{preparePagesComponent.d.ts → preparePagesComponents.d.ts} +1 -1
- package/lib/app/prepare/preparePagesComponents.js +24 -0
- package/lib/app/prepare/preparePagesData.js +5 -4
- package/lib/app/prepare/preparePagesRoutes.js +61 -11
- package/lib/app/prepare/prepareSiteData.js +19 -1
- package/lib/app/{createAppDir.d.ts → resolveAppDir.d.ts} +2 -2
- package/lib/app/resolveAppDir.js +32 -0
- 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} +16 -20
- package/lib/app/resolveAppPages.d.ts +5 -0
- package/lib/app/resolveAppPages.js +31 -0
- package/lib/app/resolveAppSiteData.d.ts +7 -0
- package/lib/app/resolveAppSiteData.js +17 -0
- 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} +5 -5
- package/lib/app/resolvePluginObject.d.ts +5 -0
- package/lib/app/resolvePluginObject.js +9 -0
- package/lib/app/resolveThemeInfo.d.ts +5 -0
- package/lib/app/resolveThemeInfo.js +31 -0
- package/lib/app/resolveThemeLayouts.d.ts +5 -0
- package/lib/app/resolveThemeLayouts.js +25 -0
- package/lib/app/setupAppThemeAndPlugins.d.ts +5 -0
- package/lib/app/setupAppThemeAndPlugins.js +21 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +5 -2
- package/lib/page/createPage.js +75 -39
- package/lib/page/index.d.ts +4 -3
- package/lib/page/index.js +9 -4
- package/lib/page/inferPagePath.js +2 -2
- package/lib/page/renderPageContent.d.ts +19 -0
- package/lib/page/renderPageContent.js +26 -0
- package/lib/page/renderPageExcerpt.d.ts +11 -0
- package/lib/page/renderPageExcerpt.js +17 -0
- package/lib/page/resolvePageComponentInfo.d.ts +2 -9
- package/lib/page/resolvePageComponentInfo.js +2 -24
- package/lib/page/resolvePageContent.js +1 -2
- package/lib/page/resolvePageDataInfo.d.ts +2 -1
- package/lib/page/resolvePageDataInfo.js +2 -2
- package/lib/page/resolvePageDate.d.ts +1 -1
- package/lib/page/resolvePageDate.js +6 -7
- package/lib/page/resolvePageFileContent.js +3 -4
- package/lib/page/resolvePageFilePath.d.ts +1 -1
- package/lib/page/resolvePageFilePath.js +6 -11
- package/lib/page/resolvePageHtmlInfo.d.ts +11 -0
- package/lib/page/resolvePageHtmlInfo.js +18 -0
- package/lib/page/resolvePageKey.js +1 -1
- package/lib/page/resolvePageLang.js +2 -3
- package/lib/page/resolvePagePath.js +12 -1
- package/lib/page/resolvePagePermalink.js +4 -5
- package/lib/page/resolvePageRouteMeta.d.ts +7 -0
- package/lib/page/resolvePageRouteMeta.js +8 -0
- package/lib/pluginApi/createHookQueue.d.ts +1 -1
- package/lib/pluginApi/createHookQueue.js +7 -46
- package/lib/pluginApi/createPluginApi.js +2 -2
- package/lib/pluginApi/createPluginApiHooks.js +15 -14
- package/lib/pluginApi/createPluginApiRegisterHooks.js +6 -6
- package/lib/pluginApi/index.js +5 -1
- package/lib/pluginApi/normalizeClientFilesHook.js +5 -2
- package/lib/pluginApi/normalizeReturnObjectHook.js +1 -1
- package/lib/types/app/app.d.ts +82 -14
- package/lib/types/app/index.js +5 -1
- package/lib/types/app/options.d.ts +78 -27
- package/lib/types/app/utils.d.ts +10 -3
- package/lib/types/bundler.d.ts +3 -24
- package/lib/types/index.d.ts +2 -3
- package/lib/types/index.js +6 -3
- package/lib/types/page.d.ts +78 -32
- package/lib/types/plugin.d.ts +5 -24
- package/lib/types/{plugin-api → pluginApi}/hooks.d.ts +8 -9
- package/lib/types/{plugin-api → pluginApi}/hooks.js +0 -0
- package/lib/types/{plugin-api → pluginApi}/index.d.ts +0 -0
- package/lib/types/{plugin-api → pluginApi}/index.js +5 -1
- package/lib/types/{plugin-api → pluginApi}/pluginApi.d.ts +0 -0
- package/lib/types/{plugin-api → pluginApi}/pluginApi.js +0 -0
- package/lib/types/theme.d.ts +42 -14
- package/package.json +14 -14
- package/CHANGELOG.md +0 -260
- package/lib/app/appUseByConfig.d.ts +0 -2
- package/lib/app/appUseByConfig.js +0 -14
- package/lib/app/createApp.d.ts +0 -5
- package/lib/app/createApp.js +0 -44
- package/lib/app/createAppDir.js +0 -32
- package/lib/app/createAppEnv.d.ts +0 -5
- package/lib/app/createAppEnv.js +0 -14
- package/lib/app/createAppOptions.d.ts +0 -5
- package/lib/app/createAppPages.d.ts +0 -5
- package/lib/app/createAppPages.js +0 -33
- package/lib/app/createAppSiteData.d.ts +0 -7
- package/lib/app/createAppSiteData.js +0 -19
- package/lib/app/createAppVersion.d.ts +0 -4
- package/lib/app/createAppVersion.js +0 -11
- package/lib/app/createAppWriteTemp.d.ts +0 -5
- package/lib/app/normalizePlugin.d.ts +0 -2
- package/lib/app/normalizePlugin.js +0 -19
- package/lib/app/normalizePluginConfig.d.ts +0 -2
- package/lib/app/normalizePluginConfig.js +0 -18
- package/lib/app/prepare/preparePageRoutes.d.ts +0 -5
- package/lib/app/prepare/preparePageRoutes.js +0 -57
- package/lib/app/prepare/preparePagesComponent.js +0 -23
- package/lib/app/prepare/resolvePageData.d.ts +0 -5
- package/lib/app/prepare/resolvePageData.js +0 -18
- package/lib/app/resolveBundler.d.ts +0 -2
- package/lib/app/resolveBundler.js +0 -10
- package/lib/app/resolvePlugin.d.ts +0 -5
- package/lib/app/resolvePlugin.js +0 -20
- package/lib/page/resolvePageExcerpt.d.ts +0 -9
- package/lib/page/resolvePageExcerpt.js +0 -15
- package/lib/page/resolvePageRoutesInfo.d.ts +0 -11
- package/lib/page/resolvePageRoutesInfo.js +0 -16
- package/lib/page/resolvePageTitle.d.ts +0 -9
- package/lib/page/resolvePageTitle.js +0 -26
- package/lib/themeApi/createThemeApi.d.ts +0 -7
- package/lib/themeApi/createThemeApi.js +0 -30
- package/lib/themeApi/index.d.ts +0 -1
- package/lib/themeApi/index.js +0 -13
- package/lib/themeApi/resolveThemeInfo.d.ts +0 -2
- package/lib/themeApi/resolveThemeInfo.js +0 -34
- package/lib/themeApi/resolveThemeLayouts.d.ts +0 -5
- package/lib/themeApi/resolveThemeLayouts.js +0 -33
- package/lib/types/theme-api/index.d.ts +0 -1
- package/lib/types/theme-api/index.js +0 -13
- package/lib/types/theme-api/themeApi.d.ts +0 -44
- package/lib/types/theme-api/themeApi.js +0 -2
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.preparePageRoutes = void 0;
|
|
4
|
-
const shared_1 = require("@vuepress/shared");
|
|
5
|
-
/**
|
|
6
|
-
* Generate page routes temp file of a single page
|
|
7
|
-
*/
|
|
8
|
-
const preparePageRoutes = async (app, { key, path, pathInferred, filePathRelative, title, routesFilePathRelative, }) => {
|
|
9
|
-
const routes = [];
|
|
10
|
-
// add page route
|
|
11
|
-
routes.push(`
|
|
12
|
-
{
|
|
13
|
-
name: ${JSON.stringify(key)},
|
|
14
|
-
path: ${JSON.stringify(path)},
|
|
15
|
-
component: Vuepress,
|
|
16
|
-
meta: { title: ${JSON.stringify(title)} },
|
|
17
|
-
},`);
|
|
18
|
-
// paths that should redirect to this page
|
|
19
|
-
const redirects = new Set();
|
|
20
|
-
// redirect from decoded path
|
|
21
|
-
redirects.add(decodeURI(path));
|
|
22
|
-
// redirect from index path
|
|
23
|
-
if (/\/$/.test(path)) {
|
|
24
|
-
const indexPath = path + 'index.html';
|
|
25
|
-
redirects.add(indexPath);
|
|
26
|
-
}
|
|
27
|
-
// redirect from inferred path
|
|
28
|
-
if (pathInferred !== null) {
|
|
29
|
-
redirects.add(pathInferred);
|
|
30
|
-
redirects.add(encodeURI(pathInferred));
|
|
31
|
-
}
|
|
32
|
-
// redirect from filename path
|
|
33
|
-
if (filePathRelative !== null) {
|
|
34
|
-
const filenamePath = shared_1.ensureLeadingSlash(filePathRelative);
|
|
35
|
-
redirects.add(filenamePath);
|
|
36
|
-
redirects.add(encodeURI(filenamePath));
|
|
37
|
-
}
|
|
38
|
-
// avoid redirect from the page path itself
|
|
39
|
-
redirects.delete(path);
|
|
40
|
-
// add redirect routes
|
|
41
|
-
redirects.forEach((redirect) => {
|
|
42
|
-
routes.push(`
|
|
43
|
-
{
|
|
44
|
-
path: ${JSON.stringify(redirect)},
|
|
45
|
-
redirect: ${JSON.stringify(path)},
|
|
46
|
-
},`);
|
|
47
|
-
});
|
|
48
|
-
const content = `\
|
|
49
|
-
import { Vuepress } from '@vuepress/client/lib/components/Vuepress'
|
|
50
|
-
|
|
51
|
-
export default [\
|
|
52
|
-
${routes.join('')}
|
|
53
|
-
]
|
|
54
|
-
`;
|
|
55
|
-
await app.writeTemp(routesFilePathRelative, content);
|
|
56
|
-
};
|
|
57
|
-
exports.preparePageRoutes = preparePageRoutes;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.preparePagesComponent = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Generate page key to page component map temp file
|
|
6
|
-
*/
|
|
7
|
-
const preparePagesComponent = async (app) => {
|
|
8
|
-
// generate page component map file
|
|
9
|
-
const content = `\
|
|
10
|
-
import { defineAsyncComponent } from 'vue'
|
|
11
|
-
|
|
12
|
-
export const pagesComponent = {\
|
|
13
|
-
${app.pages
|
|
14
|
-
.map(({ path, componentFilePath, componentFileChunkName }) => `
|
|
15
|
-
${JSON.stringify(path)}: defineAsyncComponent(() => import(${componentFileChunkName
|
|
16
|
-
? `/* webpackChunkName: "${componentFileChunkName}" */`
|
|
17
|
-
: ''}${JSON.stringify(componentFilePath)})),`)
|
|
18
|
-
.join('')}
|
|
19
|
-
}
|
|
20
|
-
`;
|
|
21
|
-
await app.writeTemp('internal/pagesComponent.js', content);
|
|
22
|
-
};
|
|
23
|
-
exports.preparePagesComponent = preparePagesComponent;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageData = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Resolve page data for client usage
|
|
6
|
-
*/
|
|
7
|
-
const resolvePageData = ({ key, path, title, lang, frontmatter, excerpt, headers, }) => {
|
|
8
|
-
return {
|
|
9
|
-
key,
|
|
10
|
-
path,
|
|
11
|
-
title,
|
|
12
|
-
lang,
|
|
13
|
-
frontmatter,
|
|
14
|
-
excerpt,
|
|
15
|
-
headers,
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
exports.resolvePageData = resolvePageData;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveBundler = void 0;
|
|
4
|
-
const shared_1 = require("@vuepress/shared");
|
|
5
|
-
const resolveBundler = ({ bundler, bundlerConfig, }) => {
|
|
6
|
-
const bundlerPackage = shared_1.normalizePackageName(bundler, 'vuepress', 'bundler');
|
|
7
|
-
const { createBundler } = require(bundlerPackage);
|
|
8
|
-
return createBundler(bundlerConfig);
|
|
9
|
-
};
|
|
10
|
-
exports.resolveBundler = resolveBundler;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Plugin, PluginObject, PluginOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve a plugin according to name or path
|
|
4
|
-
*/
|
|
5
|
-
export declare const resolvePlugin: <T extends PluginOptions = PluginOptions, U extends PluginObject = PluginObject>(pluginName: string) => Plugin<T, U> | null;
|
package/lib/app/resolvePlugin.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePlugin = void 0;
|
|
4
|
-
const shared_1 = require("@vuepress/shared");
|
|
5
|
-
const utils_1 = require("@vuepress/utils");
|
|
6
|
-
/**
|
|
7
|
-
* Resolve a plugin according to name or path
|
|
8
|
-
*/
|
|
9
|
-
const resolvePlugin = (pluginName) => {
|
|
10
|
-
const pluginEntry = utils_1.path.isAbsolute(pluginName)
|
|
11
|
-
? pluginName
|
|
12
|
-
: utils_1.requireResolve(shared_1.normalizePackageName(pluginName, 'vuepress', 'plugin'));
|
|
13
|
-
if (pluginEntry === null) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
const required = require(pluginEntry);
|
|
17
|
-
// allow default export
|
|
18
|
-
return utils_1.hasExportDefault(required) ? required.default : required;
|
|
19
|
-
};
|
|
20
|
-
exports.resolvePlugin = resolvePlugin;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageExcerpt = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Resolve page excerpt from raw excerpt
|
|
6
|
-
*/
|
|
7
|
-
const resolvePageExcerpt = ({ excerptRaw, app, filePathRelative, }) => {
|
|
8
|
-
const markdownEnv = {
|
|
9
|
-
base: app.options.base,
|
|
10
|
-
filePathRelative,
|
|
11
|
-
};
|
|
12
|
-
const html = app.markdown.render(excerptRaw, markdownEnv);
|
|
13
|
-
return html;
|
|
14
|
-
};
|
|
15
|
-
exports.resolvePageExcerpt = resolvePageExcerpt;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageRoutesInfo = void 0;
|
|
4
|
-
const utils_1 = require("@vuepress/utils");
|
|
5
|
-
/**
|
|
6
|
-
* Resolve page routes file path
|
|
7
|
-
*/
|
|
8
|
-
const resolvePageRoutesInfo = ({ app, key, }) => {
|
|
9
|
-
const routesFilePathRelative = utils_1.path.join(`internal/pageRoutes/${key}.js`);
|
|
10
|
-
const routesFilePath = app.dir.temp(routesFilePathRelative);
|
|
11
|
-
return {
|
|
12
|
-
routesFilePath,
|
|
13
|
-
routesFilePathRelative,
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
exports.resolvePageRoutesInfo = resolvePageRoutesInfo;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { PageFrontmatter, PageHeader } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Resolve page title from frontmatter / file content
|
|
4
|
-
*/
|
|
5
|
-
export declare const resolvePageTitle: ({ content, frontmatter, headers, }: {
|
|
6
|
-
content: string;
|
|
7
|
-
frontmatter: PageFrontmatter;
|
|
8
|
-
headers: PageHeader[];
|
|
9
|
-
}) => string;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolvePageTitle = void 0;
|
|
4
|
-
const markdown_1 = require("@vuepress/markdown");
|
|
5
|
-
const shared_1 = require("@vuepress/shared");
|
|
6
|
-
/**
|
|
7
|
-
* Resolve page title from frontmatter / file content
|
|
8
|
-
*/
|
|
9
|
-
const resolvePageTitle = ({ content, frontmatter, headers, }) => {
|
|
10
|
-
// use title in frontmatter
|
|
11
|
-
if (shared_1.isString(frontmatter.title)) {
|
|
12
|
-
return markdown_1.parseEmoji(frontmatter.title);
|
|
13
|
-
}
|
|
14
|
-
// if the first header is <h1>, use it as the title
|
|
15
|
-
const firstHeader = headers[0];
|
|
16
|
-
if ((firstHeader === null || firstHeader === void 0 ? void 0 : firstHeader.level) === 1) {
|
|
17
|
-
return firstHeader.title;
|
|
18
|
-
}
|
|
19
|
-
// try to get the first `# title` from markdown content
|
|
20
|
-
const matchTitle = content.trimStart().match(/^#\s+(.*)/);
|
|
21
|
-
if (matchTitle) {
|
|
22
|
-
return markdown_1.parseEmoji(matchTitle[1]);
|
|
23
|
-
}
|
|
24
|
-
return '';
|
|
25
|
-
};
|
|
26
|
-
exports.resolvePageTitle = resolvePageTitle;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createThemeApi = void 0;
|
|
4
|
-
const resolveThemeInfo_1 = require("./resolveThemeInfo");
|
|
5
|
-
/**
|
|
6
|
-
* Create vuepress theme-api
|
|
7
|
-
*
|
|
8
|
-
* Resolve current theme, parent theme, theme layouts
|
|
9
|
-
*/
|
|
10
|
-
const createThemeApi = async (app) => {
|
|
11
|
-
// resolve theme info
|
|
12
|
-
const theme = await resolveThemeInfo_1.resolveThemeInfo(app, app.options.theme);
|
|
13
|
-
// resolve parent theme info
|
|
14
|
-
const parentTheme = theme.plugin.extends
|
|
15
|
-
? await resolveThemeInfo_1.resolveThemeInfo(app, theme.plugin.extends)
|
|
16
|
-
: null;
|
|
17
|
-
// resolve theme layouts
|
|
18
|
-
const layouts = theme.layouts;
|
|
19
|
-
// layouts in child theme will override
|
|
20
|
-
// those with the same name in parent theme
|
|
21
|
-
if (parentTheme !== null) {
|
|
22
|
-
layouts.unshift(...parentTheme.layouts.filter(({ name: parentLayoutName }) => !theme.layouts.some(({ name: childLayoutName }) => childLayoutName === parentLayoutName)));
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
theme,
|
|
26
|
-
parentTheme,
|
|
27
|
-
layouts,
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
exports.createThemeApi = createThemeApi;
|
package/lib/themeApi/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './createThemeApi';
|
package/lib/themeApi/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./createThemeApi"), exports);
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveThemeInfo = void 0;
|
|
4
|
-
const shared_1 = require("@vuepress/shared");
|
|
5
|
-
const utils_1 = require("@vuepress/utils");
|
|
6
|
-
const app_1 = require("../app");
|
|
7
|
-
const resolveThemeLayouts_1 = require("./resolveThemeLayouts");
|
|
8
|
-
const resolveThemeInfo = async (app, themeName) => {
|
|
9
|
-
// resolve theme entry according to theme name
|
|
10
|
-
const themeEntry = utils_1.requireResolve(utils_1.path.isAbsolute(themeName)
|
|
11
|
-
? themeName
|
|
12
|
-
: shared_1.normalizePackageName(themeName, 'vuepress', 'theme'));
|
|
13
|
-
if (themeEntry === null) {
|
|
14
|
-
const message = `theme ${themeName} is not found`;
|
|
15
|
-
utils_1.logger.error(message);
|
|
16
|
-
throw new Error(message);
|
|
17
|
-
}
|
|
18
|
-
// normalize theme plugin from theme entry
|
|
19
|
-
const themePlugin = app_1.normalizePlugin(app, themeEntry, app.options.themeConfig);
|
|
20
|
-
// get theme path
|
|
21
|
-
const themePath = themeEntry.match(/.(js|ts)$/)
|
|
22
|
-
? utils_1.path.dirname(themeEntry)
|
|
23
|
-
: themeEntry;
|
|
24
|
-
// resolve theme layouts
|
|
25
|
-
const layouts = await resolveThemeLayouts_1.resolveThemeLayouts({
|
|
26
|
-
themePath,
|
|
27
|
-
themePlugin,
|
|
28
|
-
});
|
|
29
|
-
return {
|
|
30
|
-
plugin: themePlugin,
|
|
31
|
-
layouts,
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
exports.resolveThemeInfo = resolveThemeInfo;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveThemeLayouts = void 0;
|
|
4
|
-
const shared_1 = require("@vuepress/shared");
|
|
5
|
-
const utils_1 = require("@vuepress/utils");
|
|
6
|
-
const resolveThemeLayouts = async ({ themePath, themePlugin, }) => {
|
|
7
|
-
// use the layouts component map directly
|
|
8
|
-
if (shared_1.isPlainObject(themePlugin.layouts)) {
|
|
9
|
-
return Object.entries(themePlugin.layouts).map(([name, file]) => ({
|
|
10
|
-
name,
|
|
11
|
-
path: file,
|
|
12
|
-
}));
|
|
13
|
-
}
|
|
14
|
-
// resolve the layouts directory
|
|
15
|
-
const dirLayout = shared_1.isString(themePlugin.layouts) && utils_1.path.isAbsolute(themePlugin.layouts)
|
|
16
|
-
? themePlugin.layouts
|
|
17
|
-
: utils_1.path.resolve(themePath, 'layouts');
|
|
18
|
-
if (!(await utils_1.fs.pathExists(dirLayout))) {
|
|
19
|
-
utils_1.logger.warn(`layout path ${utils_1.chalk.magenta(dirLayout)} does not exist`);
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
// load all files in layouts directory
|
|
23
|
-
const files = await utils_1.fs.readdir(dirLayout);
|
|
24
|
-
// take matched files as theme layouts
|
|
25
|
-
const layouts = files
|
|
26
|
-
.filter((file) => /\.(vue|ts|js)$/.test(file))
|
|
27
|
-
.map((file) => ({
|
|
28
|
-
name: utils_1.path.trimExt(file),
|
|
29
|
-
path: utils_1.path.resolve(dirLayout, file),
|
|
30
|
-
}));
|
|
31
|
-
return layouts;
|
|
32
|
-
};
|
|
33
|
-
exports.resolveThemeLayouts = resolveThemeLayouts;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './themeApi';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./themeApi"), exports);
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { ThemeObject } from '../theme';
|
|
2
|
-
/**
|
|
3
|
-
* Vuepress theme system
|
|
4
|
-
*/
|
|
5
|
-
export interface ThemeApi {
|
|
6
|
-
/**
|
|
7
|
-
* Current theme
|
|
8
|
-
*/
|
|
9
|
-
theme: ThemeInfo;
|
|
10
|
-
/**
|
|
11
|
-
* Parent theme
|
|
12
|
-
*/
|
|
13
|
-
parentTheme: ThemeInfo | null;
|
|
14
|
-
/**
|
|
15
|
-
* Layouts
|
|
16
|
-
*/
|
|
17
|
-
layouts: ThemeLayout[];
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Vuepress theme info
|
|
21
|
-
*/
|
|
22
|
-
export interface ThemeInfo {
|
|
23
|
-
/**
|
|
24
|
-
* Theme plugin object
|
|
25
|
-
*/
|
|
26
|
-
plugin: ThemeObject;
|
|
27
|
-
/**
|
|
28
|
-
* Theme layouts
|
|
29
|
-
*/
|
|
30
|
-
layouts: ThemeLayout[];
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Vuepress theme layout
|
|
34
|
-
*/
|
|
35
|
-
export interface ThemeLayout {
|
|
36
|
-
/**
|
|
37
|
-
* Path of layout
|
|
38
|
-
*/
|
|
39
|
-
path: string;
|
|
40
|
-
/**
|
|
41
|
-
* Name of layout
|
|
42
|
-
*/
|
|
43
|
-
name: string;
|
|
44
|
-
}
|