@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.
Files changed (146) hide show
  1. package/lib/app/appInit.js +6 -16
  2. package/lib/app/appPrepare.js +12 -15
  3. package/lib/app/appUse.d.ts +2 -2
  4. package/lib/app/appUse.js +17 -15
  5. package/lib/app/createBaseApp.d.ts +5 -0
  6. package/lib/app/createBaseApp.js +46 -0
  7. package/lib/app/createBuildApp.d.ts +5 -0
  8. package/lib/app/createBuildApp.js +13 -0
  9. package/lib/app/createDevApp.d.ts +5 -0
  10. package/lib/app/createDevApp.js +13 -0
  11. package/lib/app/index.d.ts +13 -12
  12. package/lib/app/index.js +18 -13
  13. package/lib/app/prepare/index.d.ts +1 -3
  14. package/lib/app/prepare/index.js +6 -4
  15. package/lib/app/prepare/prepareLayoutComponents.js +2 -2
  16. package/lib/app/prepare/preparePageComponent.js +6 -1
  17. package/lib/app/prepare/preparePageData.js +7 -11
  18. package/lib/app/prepare/{preparePagesComponent.d.ts → preparePagesComponents.d.ts} +1 -1
  19. package/lib/app/prepare/preparePagesComponents.js +24 -0
  20. package/lib/app/prepare/preparePagesData.js +5 -4
  21. package/lib/app/prepare/preparePagesRoutes.js +61 -11
  22. package/lib/app/prepare/prepareSiteData.js +19 -1
  23. package/lib/app/{createAppDir.d.ts → resolveAppDir.d.ts} +2 -2
  24. package/lib/app/resolveAppDir.js +32 -0
  25. package/lib/app/resolveAppEnv.d.ts +5 -0
  26. package/lib/app/resolveAppEnv.js +12 -0
  27. package/lib/app/resolveAppMarkdown.d.ts +6 -0
  28. package/lib/app/resolveAppMarkdown.js +16 -0
  29. package/lib/app/resolveAppOptions.d.ts +5 -0
  30. package/lib/app/{createAppOptions.js → resolveAppOptions.js} +16 -20
  31. package/lib/app/resolveAppPages.d.ts +5 -0
  32. package/lib/app/resolveAppPages.js +31 -0
  33. package/lib/app/resolveAppSiteData.d.ts +7 -0
  34. package/lib/app/resolveAppSiteData.js +17 -0
  35. package/lib/app/resolveAppVersion.d.ts +4 -0
  36. package/lib/app/resolveAppVersion.js +10 -0
  37. package/lib/app/resolveAppWriteTemp.d.ts +5 -0
  38. package/lib/app/{createAppWriteTemp.js → resolveAppWriteTemp.js} +5 -5
  39. package/lib/app/resolvePluginObject.d.ts +5 -0
  40. package/lib/app/resolvePluginObject.js +9 -0
  41. package/lib/app/resolveThemeInfo.d.ts +5 -0
  42. package/lib/app/resolveThemeInfo.js +31 -0
  43. package/lib/app/resolveThemeLayouts.d.ts +5 -0
  44. package/lib/app/resolveThemeLayouts.js +25 -0
  45. package/lib/app/setupAppThemeAndPlugins.d.ts +5 -0
  46. package/lib/app/setupAppThemeAndPlugins.js +21 -0
  47. package/lib/index.d.ts +0 -1
  48. package/lib/index.js +5 -2
  49. package/lib/page/createPage.js +75 -39
  50. package/lib/page/index.d.ts +4 -3
  51. package/lib/page/index.js +9 -4
  52. package/lib/page/inferPagePath.js +2 -2
  53. package/lib/page/renderPageContent.d.ts +19 -0
  54. package/lib/page/renderPageContent.js +26 -0
  55. package/lib/page/renderPageExcerpt.d.ts +11 -0
  56. package/lib/page/renderPageExcerpt.js +17 -0
  57. package/lib/page/resolvePageComponentInfo.d.ts +2 -9
  58. package/lib/page/resolvePageComponentInfo.js +2 -24
  59. package/lib/page/resolvePageContent.js +1 -2
  60. package/lib/page/resolvePageDataInfo.d.ts +2 -1
  61. package/lib/page/resolvePageDataInfo.js +2 -2
  62. package/lib/page/resolvePageDate.d.ts +1 -1
  63. package/lib/page/resolvePageDate.js +6 -7
  64. package/lib/page/resolvePageFileContent.js +3 -4
  65. package/lib/page/resolvePageFilePath.d.ts +1 -1
  66. package/lib/page/resolvePageFilePath.js +6 -11
  67. package/lib/page/resolvePageHtmlInfo.d.ts +11 -0
  68. package/lib/page/resolvePageHtmlInfo.js +18 -0
  69. package/lib/page/resolvePageKey.js +1 -1
  70. package/lib/page/resolvePageLang.js +2 -3
  71. package/lib/page/resolvePagePath.js +12 -1
  72. package/lib/page/resolvePagePermalink.js +4 -5
  73. package/lib/page/resolvePageRouteMeta.d.ts +7 -0
  74. package/lib/page/resolvePageRouteMeta.js +8 -0
  75. package/lib/pluginApi/createHookQueue.d.ts +1 -1
  76. package/lib/pluginApi/createHookQueue.js +7 -46
  77. package/lib/pluginApi/createPluginApi.js +2 -2
  78. package/lib/pluginApi/createPluginApiHooks.js +15 -14
  79. package/lib/pluginApi/createPluginApiRegisterHooks.js +6 -6
  80. package/lib/pluginApi/index.js +5 -1
  81. package/lib/pluginApi/normalizeClientFilesHook.js +5 -2
  82. package/lib/pluginApi/normalizeReturnObjectHook.js +1 -1
  83. package/lib/types/app/app.d.ts +82 -14
  84. package/lib/types/app/index.js +5 -1
  85. package/lib/types/app/options.d.ts +78 -27
  86. package/lib/types/app/utils.d.ts +10 -3
  87. package/lib/types/bundler.d.ts +3 -24
  88. package/lib/types/index.d.ts +2 -3
  89. package/lib/types/index.js +6 -3
  90. package/lib/types/page.d.ts +78 -32
  91. package/lib/types/plugin.d.ts +5 -24
  92. package/lib/types/{plugin-api → pluginApi}/hooks.d.ts +8 -9
  93. package/lib/types/{plugin-api → pluginApi}/hooks.js +0 -0
  94. package/lib/types/{plugin-api → pluginApi}/index.d.ts +0 -0
  95. package/lib/types/{plugin-api → pluginApi}/index.js +5 -1
  96. package/lib/types/{plugin-api → pluginApi}/pluginApi.d.ts +0 -0
  97. package/lib/types/{plugin-api → pluginApi}/pluginApi.js +0 -0
  98. package/lib/types/theme.d.ts +42 -14
  99. package/package.json +14 -14
  100. package/CHANGELOG.md +0 -260
  101. package/lib/app/appUseByConfig.d.ts +0 -2
  102. package/lib/app/appUseByConfig.js +0 -14
  103. package/lib/app/createApp.d.ts +0 -5
  104. package/lib/app/createApp.js +0 -44
  105. package/lib/app/createAppDir.js +0 -32
  106. package/lib/app/createAppEnv.d.ts +0 -5
  107. package/lib/app/createAppEnv.js +0 -14
  108. package/lib/app/createAppOptions.d.ts +0 -5
  109. package/lib/app/createAppPages.d.ts +0 -5
  110. package/lib/app/createAppPages.js +0 -33
  111. package/lib/app/createAppSiteData.d.ts +0 -7
  112. package/lib/app/createAppSiteData.js +0 -19
  113. package/lib/app/createAppVersion.d.ts +0 -4
  114. package/lib/app/createAppVersion.js +0 -11
  115. package/lib/app/createAppWriteTemp.d.ts +0 -5
  116. package/lib/app/normalizePlugin.d.ts +0 -2
  117. package/lib/app/normalizePlugin.js +0 -19
  118. package/lib/app/normalizePluginConfig.d.ts +0 -2
  119. package/lib/app/normalizePluginConfig.js +0 -18
  120. package/lib/app/prepare/preparePageRoutes.d.ts +0 -5
  121. package/lib/app/prepare/preparePageRoutes.js +0 -57
  122. package/lib/app/prepare/preparePagesComponent.js +0 -23
  123. package/lib/app/prepare/resolvePageData.d.ts +0 -5
  124. package/lib/app/prepare/resolvePageData.js +0 -18
  125. package/lib/app/resolveBundler.d.ts +0 -2
  126. package/lib/app/resolveBundler.js +0 -10
  127. package/lib/app/resolvePlugin.d.ts +0 -5
  128. package/lib/app/resolvePlugin.js +0 -20
  129. package/lib/page/resolvePageExcerpt.d.ts +0 -9
  130. package/lib/page/resolvePageExcerpt.js +0 -15
  131. package/lib/page/resolvePageRoutesInfo.d.ts +0 -11
  132. package/lib/page/resolvePageRoutesInfo.js +0 -16
  133. package/lib/page/resolvePageTitle.d.ts +0 -9
  134. package/lib/page/resolvePageTitle.js +0 -26
  135. package/lib/themeApi/createThemeApi.d.ts +0 -7
  136. package/lib/themeApi/createThemeApi.js +0 -30
  137. package/lib/themeApi/index.d.ts +0 -1
  138. package/lib/themeApi/index.js +0 -13
  139. package/lib/themeApi/resolveThemeInfo.d.ts +0 -2
  140. package/lib/themeApi/resolveThemeInfo.js +0 -34
  141. package/lib/themeApi/resolveThemeLayouts.d.ts +0 -5
  142. package/lib/themeApi/resolveThemeLayouts.js +0 -33
  143. package/lib/types/theme-api/index.d.ts +0 -1
  144. package/lib/types/theme-api/index.js +0 -13
  145. package/lib/types/theme-api/themeApi.d.ts +0 -44
  146. 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,5 +0,0 @@
1
- import type { Page, PageData } from '../../types';
2
- /**
3
- * Resolve page data for client usage
4
- */
5
- export declare const resolvePageData: ({ key, path, title, lang, frontmatter, excerpt, headers, }: Page) => PageData;
@@ -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,2 +0,0 @@
1
- import type { AppOptions, Bundler } from '../types';
2
- export declare const resolveBundler: ({ bundler, bundlerConfig, }: AppOptions) => Bundler;
@@ -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;
@@ -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,9 +0,0 @@
1
- import type { App } from '../types';
2
- /**
3
- * Resolve page excerpt from raw excerpt
4
- */
5
- export declare const resolvePageExcerpt: ({ excerptRaw, app, filePathRelative, }: {
6
- excerptRaw: string;
7
- app: App;
8
- filePathRelative: string | null;
9
- }) => string;
@@ -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,11 +0,0 @@
1
- import type { App } from '../types';
2
- /**
3
- * Resolve page routes file path
4
- */
5
- export declare const resolvePageRoutesInfo: ({ app, key, }: {
6
- app: App;
7
- key: string;
8
- }) => {
9
- routesFilePath: string;
10
- routesFilePathRelative: string;
11
- };
@@ -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,7 +0,0 @@
1
- import type { App, ThemeApi } from '../types';
2
- /**
3
- * Create vuepress theme-api
4
- *
5
- * Resolve current theme, parent theme, theme layouts
6
- */
7
- export declare const createThemeApi: (app: App) => Promise<ThemeApi>;
@@ -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;
@@ -1 +0,0 @@
1
- export * from './createThemeApi';
@@ -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,2 +0,0 @@
1
- import type { App, ThemeInfo } from '../types';
2
- export declare const resolveThemeInfo: (app: App, themeName: string) => Promise<ThemeInfo>;
@@ -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,5 +0,0 @@
1
- import type { ThemeObject, ThemeLayout } from '../types';
2
- export declare const resolveThemeLayouts: ({ themePath, themePlugin, }: {
3
- themePath: string;
4
- themePlugin: ThemeObject;
5
- }) => Promise<ThemeLayout[]>;
@@ -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
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });