@vuepress/core 2.0.0-beta.24 → 2.0.0-beta.28

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 (61) hide show
  1. package/lib/app/appInit.js +5 -4
  2. package/lib/app/appPrepare.js +11 -11
  3. package/lib/app/appUse.js +3 -3
  4. package/lib/app/createAppDir.js +6 -6
  5. package/lib/app/createAppMarkdown.d.ts +6 -0
  6. package/lib/app/createAppMarkdown.js +16 -0
  7. package/lib/app/createAppPages.js +14 -5
  8. package/lib/app/createBaseApp.js +16 -19
  9. package/lib/app/createBuildApp.d.ts +1 -1
  10. package/lib/app/createBuildApp.js +2 -2
  11. package/lib/app/createDevApp.d.ts +1 -1
  12. package/lib/app/createDevApp.js +2 -2
  13. package/lib/app/index.d.ts +1 -1
  14. package/lib/app/index.js +1 -1
  15. package/lib/app/normalizePluginConfig.d.ts +1 -1
  16. package/lib/app/normalizePluginConfig.js +1 -1
  17. package/lib/app/prepare/preparePagesRoutes.js +5 -5
  18. package/lib/app/resolveBundler.js +1 -1
  19. package/lib/app/resolvePlugin.js +3 -3
  20. package/lib/app/resolvePluginModule.js +2 -2
  21. package/lib/app/resolvePluginsFromConfig.js +2 -2
  22. package/lib/app/resolveTheme.js +3 -3
  23. package/lib/app/resolveThemeInfo.d.ts +5 -0
  24. package/lib/app/resolveThemeInfo.js +28 -0
  25. package/lib/app/resolveThemeLayouts.js +1 -1
  26. package/lib/page/createPage.d.ts +1 -1
  27. package/lib/page/createPage.js +32 -24
  28. package/lib/page/index.d.ts +1 -2
  29. package/lib/page/index.js +1 -2
  30. package/lib/page/inferPagePath.js +2 -2
  31. package/lib/page/resolvePageContent.js +1 -1
  32. package/lib/page/resolvePageDate.d.ts +1 -1
  33. package/lib/page/resolvePageDate.js +5 -5
  34. package/lib/page/resolvePageFileContent.js +2 -2
  35. package/lib/page/resolvePageFilePath.d.ts +1 -1
  36. package/lib/page/resolvePageFilePath.js +6 -11
  37. package/lib/page/resolvePageHtmlInfo.js +1 -1
  38. package/lib/page/resolvePageKey.js +1 -1
  39. package/lib/page/resolvePageLang.js +1 -1
  40. package/lib/page/resolvePagePath.js +2 -2
  41. package/lib/page/resolvePagePermalink.js +3 -3
  42. package/lib/page/resolvePageRouteMeta.d.ts +7 -0
  43. package/lib/page/resolvePageRouteMeta.js +8 -0
  44. package/lib/pluginApi/createHookQueue.js +3 -3
  45. package/lib/pluginApi/createPluginApi.js +2 -2
  46. package/lib/pluginApi/createPluginApiHooks.js +14 -14
  47. package/lib/pluginApi/createPluginApiRegisterHooks.js +6 -6
  48. package/lib/pluginApi/normalizeClientFilesHook.js +2 -2
  49. package/lib/pluginApi/normalizeReturnObjectHook.js +1 -1
  50. package/lib/types/app/app.d.ts +7 -5
  51. package/lib/types/index.d.ts +1 -1
  52. package/lib/types/page.d.ts +29 -5
  53. package/lib/types/pluginApi/hooks.d.ts +6 -7
  54. package/lib/types/theme.d.ts +13 -0
  55. package/package.json +6 -6
  56. package/lib/app/resolveThemeApi.d.ts +0 -8
  57. package/lib/app/resolveThemeApi.js +0 -29
  58. package/lib/page/resolvePageData.d.ts +0 -8
  59. package/lib/page/resolvePageData.js +0 -23
  60. package/lib/page/resolvePageOptions.d.ts +0 -8
  61. package/lib/page/resolvePageOptions.js +0 -14
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.appInit = void 0;
4
4
  const utils_1 = require("@vuepress/utils");
5
+ const createAppMarkdown_1 = require("./createAppMarkdown");
5
6
  const createAppPages_1 = require("./createAppPages");
6
- const log = utils_1.debug('vuepress:core/app');
7
+ const log = (0, utils_1.debug)('vuepress:core/app');
7
8
  /**
8
9
  * Initialize a vuepress app
9
10
  *
@@ -15,10 +16,10 @@ const appInit = async (app) => {
15
16
  // plugins should be used before `registerHooks()`
16
17
  // hooks in plugins will take effect after `registerHooks()`
17
18
  app.pluginApi.registerHooks();
18
- // plugin hook: extendsMarkdown
19
- await app.pluginApi.hooks.extendsMarkdown.process(app.markdown, app);
19
+ // create markdown
20
+ app.markdown = await (0, createAppMarkdown_1.createAppMarkdown)(app);
20
21
  // create pages
21
- app.pages = await createAppPages_1.createAppPages(app);
22
+ app.pages = await (0, createAppPages_1.createAppPages)(app);
22
23
  // plugin hook: onInitialized
23
24
  await app.pluginApi.hooks.onInitialized.process(app);
24
25
  log('init finish');
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.appPrepare = void 0;
4
4
  const utils_1 = require("@vuepress/utils");
5
5
  const prepare_1 = require("./prepare");
6
- const log = utils_1.debug('vuepress:core/app');
6
+ const log = (0, utils_1.debug)('vuepress:core/app');
7
7
  /**
8
8
  * Prepare files for development or build
9
9
  *
@@ -16,26 +16,26 @@ const appPrepare = async (app) => {
16
16
  log('prepare start');
17
17
  // generate page component files
18
18
  for (const page of app.pages) {
19
- await prepare_1.preparePageComponent(app, page);
19
+ await (0, prepare_1.preparePageComponent)(app, page);
20
20
  }
21
- await prepare_1.preparePagesComponents(app);
21
+ await (0, prepare_1.preparePagesComponents)(app);
22
22
  // generate page data files
23
23
  for (const page of app.pages) {
24
- await prepare_1.preparePageData(app, page);
24
+ await (0, prepare_1.preparePageData)(app, page);
25
25
  }
26
- await prepare_1.preparePagesData(app);
26
+ await (0, prepare_1.preparePagesData)(app);
27
27
  // generate routes file
28
- await prepare_1.preparePagesRoutes(app);
28
+ await (0, prepare_1.preparePagesRoutes)(app);
29
29
  // generate layout components map file
30
- await prepare_1.prepareLayoutComponents(app);
30
+ await (0, prepare_1.prepareLayoutComponents)(app);
31
31
  // generate site data file
32
- await prepare_1.prepareSiteData(app);
32
+ await (0, prepare_1.prepareSiteData)(app);
33
33
  // generate client app enhances file
34
- await prepare_1.prepareClientAppEnhances(app);
34
+ await (0, prepare_1.prepareClientAppEnhances)(app);
35
35
  // generate client app root components file
36
- await prepare_1.prepareClientAppRootComponents(app);
36
+ await (0, prepare_1.prepareClientAppRootComponents)(app);
37
37
  // generate client app setups file
38
- await prepare_1.prepareClientAppSetups(app);
38
+ await (0, prepare_1.prepareClientAppSetups)(app);
39
39
  // plugin hook: onPrepared
40
40
  await app.pluginApi.hooks.onPrepared.process(app);
41
41
  log('prepare finish');
package/lib/app/appUse.js CHANGED
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.appUse = void 0;
4
4
  const utils_1 = require("@vuepress/utils");
5
5
  const resolvePlugin_1 = require("./resolvePlugin");
6
- const log = utils_1.debug('vuepress:core/app');
6
+ const log = (0, utils_1.debug)('vuepress:core/app');
7
7
  const appUse = (app, rawPlugin, config) => {
8
- const plugin = resolvePlugin_1.resolvePlugin(app, rawPlugin, config);
8
+ const plugin = (0, resolvePlugin_1.resolvePlugin)(app, rawPlugin, config);
9
9
  log(`use plugin ${utils_1.chalk.magenta(plugin.name)}`);
10
10
  if (plugin.multiple !== true) {
11
11
  // remove duplicated plugin
@@ -13,7 +13,7 @@ const appUse = (app, rawPlugin, config) => {
13
13
  if (duplicateIndex !== -1) {
14
14
  app.pluginApi.plugins.splice(duplicateIndex, 1);
15
15
  // show warning when duplicate plugins are detected
16
- utils_1.warn(`plugin ${utils_1.chalk.magenta(plugin.name)} has been used multiple times, only the last one will take effect`);
16
+ (0, utils_1.warn)(`plugin ${utils_1.chalk.magenta(plugin.name)} has been used multiple times, only the last one will take effect`);
17
17
  }
18
18
  }
19
19
  // use plugin
@@ -13,13 +13,13 @@ exports.createAppDirFunction = createAppDirFunction;
13
13
  * Create directory utils for vuepress app
14
14
  */
15
15
  const createAppDir = (options) => {
16
- const cache = exports.createAppDirFunction(options.cache);
17
- const temp = exports.createAppDirFunction(options.temp);
18
- const source = exports.createAppDirFunction(options.source);
19
- const dest = exports.createAppDirFunction(options.dest);
20
- const publicDir = exports.createAppDirFunction(options.public);
16
+ const cache = (0, exports.createAppDirFunction)(options.cache);
17
+ const temp = (0, exports.createAppDirFunction)(options.temp);
18
+ const source = (0, exports.createAppDirFunction)(options.source);
19
+ const dest = (0, exports.createAppDirFunction)(options.dest);
20
+ const publicDir = (0, exports.createAppDirFunction)(options.public);
21
21
  // @vuepress/client
22
- const client = exports.createAppDirFunction(utils_1.path.resolve(require.resolve('@vuepress/client/package.json'), '..'));
22
+ const client = (0, exports.createAppDirFunction)(utils_1.path.resolve(require.resolve('@vuepress/client/package.json'), '..'));
23
23
  return {
24
24
  cache,
25
25
  temp,
@@ -0,0 +1,6 @@
1
+ import type { Markdown } from '@vuepress/markdown';
2
+ import type { App } from '../types';
3
+ /**
4
+ * Create markdown-it instance for vuepress app
5
+ */
6
+ export declare const createAppMarkdown: (app: App) => Promise<Markdown>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAppMarkdown = void 0;
4
+ const markdown_1 = require("@vuepress/markdown");
5
+ /**
6
+ * Create markdown-it instance for vuepress app
7
+ */
8
+ const createAppMarkdown = async (app) => {
9
+ // plugin hook: extendsMarkdownOptions
10
+ await app.pluginApi.hooks.extendsMarkdownOptions.process(app.options.markdown, app);
11
+ const markdown = (0, markdown_1.createMarkdown)(app.options.markdown);
12
+ // plugin hook: extendsMarkdown
13
+ await app.pluginApi.hooks.extendsMarkdown.process(markdown, app);
14
+ return markdown;
15
+ };
16
+ exports.createAppMarkdown = createAppMarkdown;
@@ -3,21 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createAppPages = void 0;
4
4
  const utils_1 = require("@vuepress/utils");
5
5
  const page_1 = require("../page");
6
- const log = utils_1.debug('vuepress:core/app');
6
+ const log = (0, utils_1.debug)('vuepress:core/app');
7
7
  /**
8
8
  * Create pages for vuepress app
9
9
  */
10
10
  const createAppPages = async (app) => {
11
11
  log('createAppPages start');
12
- // resolve page file paths according to the page patterns
13
- const pagePaths = await utils_1.globby(app.options.pagePatterns, {
12
+ // resolve page absolute file paths according to the page patterns
13
+ const pageFilePaths = await (0, utils_1.globby)(app.options.pagePatterns, {
14
+ absolute: true,
14
15
  cwd: app.dir.source(),
15
16
  });
16
17
  // create pages from files
17
- const pages = await Promise.all(pagePaths.map((filePath) => page_1.createPage(app, { filePath })));
18
+ const pages = await Promise.all(pageFilePaths.map(async (filePath) => {
19
+ const pageOptions = { filePath };
20
+ // plugin hook: extendsPageOptions
21
+ await app.pluginApi.hooks.extendsPageOptions.process(pageOptions, app);
22
+ const page = await (0, page_1.createPage)(app, pageOptions);
23
+ // plugin hook: extendsPage
24
+ await app.pluginApi.hooks.extendsPage.process(page, app);
25
+ return page;
26
+ }));
18
27
  // if there is no 404 page, add one
19
28
  if (!pages.some((page) => page.path === '/404.html')) {
20
- pages.push(await page_1.createPage(app, {
29
+ pages.push(await (0, page_1.createPage)(app, {
21
30
  path: '/404.html',
22
31
  frontmatter: {
23
32
  layout: '404',
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createBaseApp = void 0;
4
- const markdown_1 = require("@vuepress/markdown");
5
4
  const pluginApi_1 = require("../pluginApi");
6
5
  const appInit_1 = require("./appInit");
7
6
  const appPrepare_1 = require("./appPrepare");
@@ -13,38 +12,36 @@ const createAppSiteData_1 = require("./createAppSiteData");
13
12
  const createAppVersion_1 = require("./createAppVersion");
14
13
  const createAppWriteTemp_1 = require("./createAppWriteTemp");
15
14
  const resolvePluginsFromConfig_1 = require("./resolvePluginsFromConfig");
16
- const resolveThemeApi_1 = require("./resolveThemeApi");
15
+ const resolveThemeInfo_1 = require("./resolveThemeInfo");
17
16
  /**
18
17
  * Create vuepress app
19
18
  */
20
19
  const createBaseApp = (config, isBuild = false) => {
21
- const version = createAppVersion_1.createAppVersion();
22
- const options = createAppOptions_1.createAppOptions(config);
23
- const dir = createAppDir_1.createAppDir(options);
24
- const env = createAppEnv_1.createAppEnv(options, isBuild);
25
- const siteData = createAppSiteData_1.createAppSiteData(options);
26
- const markdown = markdown_1.createMarkdown(options.markdown);
27
- const pluginApi = pluginApi_1.createPluginApi();
28
- const writeTemp = createAppWriteTemp_1.createAppWriteTemp(dir);
20
+ const version = (0, createAppVersion_1.createAppVersion)();
21
+ const options = (0, createAppOptions_1.createAppOptions)(config);
22
+ const dir = (0, createAppDir_1.createAppDir)(options);
23
+ const env = (0, createAppEnv_1.createAppEnv)(options, isBuild);
24
+ const siteData = (0, createAppSiteData_1.createAppSiteData)(options);
25
+ const pluginApi = (0, pluginApi_1.createPluginApi)();
26
+ const writeTemp = (0, createAppWriteTemp_1.createAppWriteTemp)(dir);
29
27
  const app = {
30
28
  version,
31
29
  options,
32
30
  dir,
33
31
  env,
34
32
  siteData,
35
- markdown,
36
33
  pluginApi,
37
34
  writeTemp,
38
- use: (...args) => appUse_1.appUse(app, ...args),
39
- init: () => appInit_1.appInit(app),
40
- prepare: () => appPrepare_1.appPrepare(app),
35
+ use: (...args) => (0, appUse_1.appUse)(app, ...args),
36
+ init: () => (0, appInit_1.appInit)(app),
37
+ prepare: () => (0, appPrepare_1.appPrepare)(app),
41
38
  };
42
- // resolve theme plugins and layouts
43
- const themeApi = resolveThemeApi_1.resolveThemeApi(app, options.theme);
44
- themeApi.plugins.forEach((plugin) => app.use(plugin));
45
- app.layouts = themeApi.layouts;
39
+ // resolve theme info and use theme plugins
40
+ const themeInfo = (0, resolveThemeInfo_1.resolveThemeInfo)(app, options.theme);
41
+ themeInfo.plugins.forEach((plugin) => app.use(plugin));
42
+ app.layouts = themeInfo.layouts;
46
43
  // resolve plugins
47
- const plugins = resolvePluginsFromConfig_1.resolvePluginsFromConfig(app, options.plugins);
44
+ const plugins = (0, resolvePluginsFromConfig_1.resolvePluginsFromConfig)(app, options.plugins);
48
45
  plugins.forEach((plugin) => app.use(plugin));
49
46
  return app;
50
47
  };
@@ -1,4 +1,4 @@
1
- import type { BuildApp, AppConfig } from '../types';
1
+ import type { AppConfig, BuildApp } from '../types';
2
2
  /**
3
3
  * Create vuepress build app
4
4
  */
@@ -7,8 +7,8 @@ const resolveBundler_1 = require("./resolveBundler");
7
7
  * Create vuepress build app
8
8
  */
9
9
  const createBuildApp = (config) => {
10
- const app = createBaseApp_1.createBaseApp(config, true);
11
- app.build = () => resolveBundler_1.resolveBundler(app.options).build(app);
10
+ const app = (0, createBaseApp_1.createBaseApp)(config, true);
11
+ app.build = () => (0, resolveBundler_1.resolveBundler)(app.options).build(app);
12
12
  return app;
13
13
  };
14
14
  exports.createBuildApp = createBuildApp;
@@ -1,4 +1,4 @@
1
- import type { DevApp, AppConfig } from '../types';
1
+ import type { AppConfig, DevApp } from '../types';
2
2
  /**
3
3
  * Create vuepress dev app
4
4
  */
@@ -7,8 +7,8 @@ const resolveBundler_1 = require("./resolveBundler");
7
7
  * Create vuepress dev app
8
8
  */
9
9
  const createDevApp = (config) => {
10
- const app = createBaseApp_1.createBaseApp(config, false);
11
- app.dev = () => resolveBundler_1.resolveBundler(app.options).dev(app);
10
+ const app = (0, createBaseApp_1.createBaseApp)(config, false);
11
+ app.dev = () => (0, resolveBundler_1.resolveBundler)(app.options).dev(app);
12
12
  return app;
13
13
  };
14
14
  exports.createDevApp = createDevApp;
@@ -18,5 +18,5 @@ export * from './resolvePlugin';
18
18
  export * from './resolvePluginModule';
19
19
  export * from './resolvePluginsFromConfig';
20
20
  export * from './resolveTheme';
21
- export * from './resolveThemeApi';
21
+ export * from './resolveThemeInfo';
22
22
  export * from './resolveThemeLayouts';
package/lib/app/index.js CHANGED
@@ -30,5 +30,5 @@ __exportStar(require("./resolvePlugin"), exports);
30
30
  __exportStar(require("./resolvePluginModule"), exports);
31
31
  __exportStar(require("./resolvePluginsFromConfig"), exports);
32
32
  __exportStar(require("./resolveTheme"), exports);
33
- __exportStar(require("./resolveThemeApi"), exports);
33
+ __exportStar(require("./resolveThemeInfo"), exports);
34
34
  __exportStar(require("./resolveThemeLayouts"), exports);
@@ -1,2 +1,2 @@
1
- import type { PluginOptions, PluginConfig, PluginConfigNormalized } from '../types';
1
+ import type { PluginConfig, PluginConfigNormalized, PluginOptions } from '../types';
2
2
  export declare const normalizePluginConfig: <T extends PluginOptions>(pluginConfig: PluginConfig<T>) => PluginConfigNormalized<T>;
@@ -6,7 +6,7 @@ const normalizePluginConfig = (pluginConfig) => {
6
6
  var _a;
7
7
  // ['container'] -> ['container', true]
8
8
  // ['container', options] -> ['container', options]
9
- if (shared_1.isArray(pluginConfig)) {
9
+ if ((0, shared_1.isArray)(pluginConfig)) {
10
10
  return [pluginConfig[0], (_a = pluginConfig[1]) !== null && _a !== void 0 ? _a : true];
11
11
  }
12
12
  // 'container' -> ['container', true]
@@ -11,9 +11,9 @@ import { Vuepress } from '@vuepress/client/lib/components/Vuepress'
11
11
 
12
12
  const routeItems = [\
13
13
  ${app.pages
14
- .map(({ key, path, pathInferred, filePathRelative, title }) => {
14
+ .map(({ key, path, pathInferred, filePathRelative, routeMeta }) => {
15
15
  const redirects = [];
16
- const routeItem = [key, path, title, redirects];
16
+ const routeItem = [key, path, routeMeta, redirects];
17
17
  // paths that should redirect to this page
18
18
  const redirectsSet = new Set();
19
19
  // redirect from decoded path
@@ -33,7 +33,7 @@ ${app.pages
33
33
  }
34
34
  // redirect from filename path
35
35
  if (filePathRelative !== null) {
36
- const filenamePath = shared_1.ensureLeadingSlash(filePathRelative);
36
+ const filenamePath = (0, shared_1.ensureLeadingSlash)(filePathRelative);
37
37
  redirectsSet.add(filenamePath);
38
38
  redirectsSet.add(encodeURI(filenamePath));
39
39
  }
@@ -47,13 +47,13 @@ ${app.pages
47
47
  ]
48
48
 
49
49
  export const pagesRoutes = routeItems.reduce(
50
- (result, [name, path, title, redirects]) => {
50
+ (result, [name, path, meta, redirects]) => {
51
51
  result.push(
52
52
  {
53
53
  name,
54
54
  path,
55
55
  component: Vuepress,
56
- meta: { title },
56
+ meta,
57
57
  },
58
58
  ...redirects.map((item) => ({
59
59
  path: item,
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveBundler = void 0;
4
4
  const shared_1 = require("@vuepress/shared");
5
5
  const resolveBundler = ({ bundler, bundlerConfig, }) => {
6
- const bundlerPackage = shared_1.normalizePackageName(bundler, 'vuepress', 'bundler');
6
+ const bundlerPackage = (0, shared_1.normalizePackageName)(bundler, 'vuepress', 'bundler');
7
7
  const { createBundler } = require(bundlerPackage);
8
8
  return createBundler(bundlerConfig);
9
9
  };
@@ -8,13 +8,13 @@ const resolvePluginModule_1 = require("./resolvePluginModule");
8
8
  * Resolve a plugin according to name / path / module and config
9
9
  */
10
10
  const resolvePlugin = (app, plugin, config = {}) => {
11
- const pluginModule = shared_1.isString(plugin)
12
- ? resolvePluginModule_1.resolvePluginModule(plugin)
11
+ const pluginModule = (0, shared_1.isString)(plugin)
12
+ ? (0, resolvePluginModule_1.resolvePluginModule)(plugin)
13
13
  : plugin;
14
14
  if (pluginModule === null) {
15
15
  throw utils_1.logger.createError(`plugin is not found: ${utils_1.chalk.magenta(plugin)}`);
16
16
  }
17
- const pluginObject = shared_1.isFunction(pluginModule)
17
+ const pluginObject = (0, shared_1.isFunction)(pluginModule)
18
18
  ? pluginModule(config, app)
19
19
  : pluginModule;
20
20
  return pluginObject;
@@ -9,12 +9,12 @@ const utils_1 = require("@vuepress/utils");
9
9
  const resolvePluginModule = (pluginName) => {
10
10
  const pluginEntry = utils_1.path.isAbsolute(pluginName)
11
11
  ? pluginName
12
- : utils_1.requireResolve(shared_1.normalizePackageName(pluginName, 'vuepress', 'plugin'));
12
+ : (0, utils_1.requireResolve)((0, shared_1.normalizePackageName)(pluginName, 'vuepress', 'plugin'));
13
13
  if (pluginEntry === null) {
14
14
  return null;
15
15
  }
16
16
  const pluginModule = require(pluginEntry);
17
17
  // allow default export
18
- return utils_1.hasExportDefault(pluginModule) ? pluginModule.default : pluginModule;
18
+ return (0, utils_1.hasExportDefault)(pluginModule) ? pluginModule.default : pluginModule;
19
19
  };
20
20
  exports.resolvePluginModule = resolvePluginModule;
@@ -7,9 +7,9 @@ const resolvePlugin_1 = require("./resolvePlugin");
7
7
  * Resolve plugins from plugin config array
8
8
  */
9
9
  const resolvePluginsFromConfig = (app, plugins = []) => plugins.reduce((prev, item) => {
10
- const [plugin, config] = normalizePluginConfig_1.normalizePluginConfig(item);
10
+ const [plugin, config] = (0, normalizePluginConfig_1.normalizePluginConfig)(item);
11
11
  if (config !== false) {
12
- prev.push(resolvePlugin_1.resolvePlugin(app, plugin, config === true ? {} : config));
12
+ prev.push((0, resolvePlugin_1.resolvePlugin)(app, plugin, config === true ? {} : config));
13
13
  }
14
14
  return prev;
15
15
  }, []);
@@ -9,14 +9,14 @@ const resolvePlugin_1 = require("./resolvePlugin");
9
9
  */
10
10
  const resolveTheme = (app, themeName) => {
11
11
  // resolve theme entry according to theme name
12
- const themeEntry = utils_1.requireResolve(utils_1.path.isAbsolute(themeName)
12
+ const themeEntry = (0, utils_1.requireResolve)(utils_1.path.isAbsolute(themeName)
13
13
  ? themeName
14
- : shared_1.normalizePackageName(themeName, 'vuepress', 'theme'));
14
+ : (0, shared_1.normalizePackageName)(themeName, 'vuepress', 'theme'));
15
15
  if (themeEntry === null) {
16
16
  throw utils_1.logger.createError(`theme is not found: ${utils_1.chalk.magenta(themeName)}`);
17
17
  }
18
18
  // resolve theme from theme entry
19
- const theme = resolvePlugin_1.resolvePlugin(app, themeEntry, app.options.themeConfig);
19
+ const theme = (0, resolvePlugin_1.resolvePlugin)(app, themeEntry, app.options.themeConfig);
20
20
  return theme;
21
21
  };
22
22
  exports.resolveTheme = resolveTheme;
@@ -0,0 +1,5 @@
1
+ import type { App, ThemeInfo } from '../types';
2
+ /**
3
+ * Resolve theme info and its parent theme info
4
+ */
5
+ export declare const resolveThemeInfo: (app: App, themeName: string) => ThemeInfo;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveThemeInfo = void 0;
4
+ const resolvePluginsFromConfig_1 = require("./resolvePluginsFromConfig");
5
+ const resolveTheme_1 = require("./resolveTheme");
6
+ const resolveThemeLayouts_1 = require("./resolveThemeLayouts");
7
+ /**
8
+ * Resolve theme info and its parent theme info
9
+ */
10
+ const resolveThemeInfo = (app, themeName) => {
11
+ // resolve current theme info
12
+ const theme = (0, resolveTheme_1.resolveTheme)(app, themeName);
13
+ const themeInfo = {
14
+ layouts: (0, resolveThemeLayouts_1.resolveThemeLayouts)(theme.layouts),
15
+ plugins: [theme, ...(0, resolvePluginsFromConfig_1.resolvePluginsFromConfig)(app, theme.plugins)],
16
+ };
17
+ // return if current theme does not have a parent theme
18
+ if (!theme.extends) {
19
+ return themeInfo;
20
+ }
21
+ // resolve parent theme info recursively
22
+ const parentThemeInfo = (0, exports.resolveThemeInfo)(app, theme.extends);
23
+ return {
24
+ layouts: { ...parentThemeInfo.layouts, ...themeInfo.layouts },
25
+ plugins: [...parentThemeInfo.plugins, ...themeInfo.plugins],
26
+ };
27
+ };
28
+ exports.resolveThemeInfo = resolveThemeInfo;
@@ -8,7 +8,7 @@ const utils_1 = require("@vuepress/utils");
8
8
  */
9
9
  const resolveThemeLayouts = (layouts = {}) => {
10
10
  // use the layouts component map directly
11
- if (shared_1.isPlainObject(layouts)) {
11
+ if ((0, shared_1.isPlainObject)(layouts)) {
12
12
  return layouts;
13
13
  }
14
14
  // resolve the layouts directory
@@ -1,2 +1,2 @@
1
1
  import type { App, Page, PageOptions } from '../types';
2
- export declare const createPage: (app: App, optionsRaw: PageOptions) => Promise<Page>;
2
+ export declare const createPage: (app: App, options: PageOptions) => Promise<Page>;
@@ -7,7 +7,6 @@ const renderPageExcerpt_1 = require("./renderPageExcerpt");
7
7
  const resolvePageComponentInfo_1 = require("./resolvePageComponentInfo");
8
8
  const resolvePageContent_1 = require("./resolvePageContent");
9
9
  const resolvePageDataInfo_1 = require("./resolvePageDataInfo");
10
- const resolvePageData_1 = require("./resolvePageData");
11
10
  const resolvePageDate_1 = require("./resolvePageDate");
12
11
  const resolvePageFileContent_1 = require("./resolvePageFileContent");
13
12
  const resolvePageFilePath_1 = require("./resolvePageFilePath");
@@ -15,28 +14,26 @@ 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, optionsRaw) => {
23
- // resolve page options from raw options
24
- const options = await resolvePageOptions_1.resolvePageOptions({ app, optionsRaw });
21
+ const createPage = async (app, options) => {
25
22
  // resolve page file absolute path and relative path
26
- const { filePath, filePathRelative } = resolvePageFilePath_1.resolvePageFilePath({
23
+ const { filePath, filePathRelative } = (0, resolvePageFilePath_1.resolvePageFilePath)({
27
24
  app,
28
25
  options,
29
26
  });
30
27
  // read the raw file content according to the absolute file path
31
- const contentRaw = await resolvePageFileContent_1.resolvePageFileContent({ filePath, options });
28
+ const contentRaw = await (0, resolvePageFileContent_1.resolvePageFileContent)({ filePath, options });
32
29
  // resolve content & frontmatter & raw excerpt from raw content
33
- const { content, frontmatterRaw, excerptRaw } = resolvePageContent_1.resolvePageContent({
30
+ const { content, frontmatterRaw, excerptRaw } = (0, resolvePageContent_1.resolvePageContent)({
34
31
  contentRaw,
35
32
  });
36
33
  // resolve frontmatter from raw frontmatter and page options
37
- const frontmatter = resolvePageFrontmatter_1.resolvePageFrontmatter({ frontmatterRaw, options });
34
+ const frontmatter = (0, resolvePageFrontmatter_1.resolvePageFrontmatter)({ frontmatterRaw, options });
38
35
  // render excerpt
39
- const excerpt = renderPageExcerpt_1.renderPageExcerpt({
36
+ const excerpt = (0, renderPageExcerpt_1.renderPageExcerpt)({
40
37
  app,
41
38
  excerptRaw,
42
39
  filePath,
@@ -44,23 +41,25 @@ const createPage = async (app, optionsRaw) => {
44
41
  frontmatter,
45
42
  });
46
43
  // render page content and extract information
47
- const { contentRendered, deps, headers, hoistedTags, links, title, } = await renderPageContent_1.renderPageContent({
44
+ const { contentRendered, deps, headers, hoistedTags, links, title } = await (0, renderPageContent_1.renderPageContent)({
48
45
  app,
49
46
  content,
50
47
  filePath,
51
48
  filePathRelative,
52
49
  frontmatter,
53
50
  });
51
+ // resolve route meta from frontmatter
52
+ const routeMeta = (0, resolvePageRouteMeta_1.resolvePageRouteMeta)({ frontmatter });
54
53
  // resolve slug from file path
55
- const slug = resolvePageSlug_1.resolvePageSlug({ filePathRelative });
54
+ const slug = (0, resolvePageSlug_1.resolvePageSlug)({ filePathRelative });
56
55
  // resolve date from file path
57
- const date = resolvePageDate_1.resolvePageDate({ frontmatter, filePathRelative });
56
+ const date = (0, resolvePageDate_1.resolvePageDate)({ frontmatter, filePathRelative });
58
57
  // infer page path according to file path
59
- const { pathInferred, pathLocale } = inferPagePath_1.inferPagePath({ app, filePathRelative });
58
+ const { pathInferred, pathLocale } = (0, inferPagePath_1.inferPagePath)({ app, filePathRelative });
60
59
  // resolve language from frontmatter and site options
61
- const lang = resolvePageLang_1.resolvePageLang({ app, frontmatter, pathLocale });
60
+ const lang = (0, resolvePageLang_1.resolvePageLang)({ app, frontmatter, pathLocale });
62
61
  // resolve page permalink
63
- const permalink = resolvePagePermalink_1.resolvePagePermalink({
62
+ const permalink = (0, resolvePagePermalink_1.resolvePagePermalink)({
64
63
  frontmatter,
65
64
  slug,
66
65
  date,
@@ -68,23 +67,33 @@ const createPage = async (app, optionsRaw) => {
68
67
  pathLocale,
69
68
  });
70
69
  // resolve page path
71
- const path = resolvePagePath_1.resolvePagePath({ permalink, pathInferred, options });
72
- // resolve path key
73
- const key = resolvePageKey_1.resolvePageKey({ path });
70
+ const path = (0, resolvePagePath_1.resolvePagePath)({ permalink, pathInferred, options });
71
+ // resolve page key
72
+ const key = (0, resolvePageKey_1.resolvePageKey)({ path });
74
73
  // resolve page rendered html file path
75
- const { htmlFilePath, htmlFilePathRelative } = resolvePageHtmlInfo_1.resolvePageHtmlInfo({
74
+ const { htmlFilePath, htmlFilePathRelative } = (0, resolvePageHtmlInfo_1.resolvePageHtmlInfo)({
76
75
  app,
77
76
  path,
78
77
  });
79
78
  // resolve page component and extract headers & links
80
- const { componentFilePath, componentFilePathRelative, componentFileChunkName, } = await resolvePageComponentInfo_1.resolvePageComponentInfo({
79
+ const { componentFilePath, componentFilePathRelative, componentFileChunkName, } = await (0, resolvePageComponentInfo_1.resolvePageComponentInfo)({
81
80
  app,
82
81
  hoistedTags,
83
82
  htmlFilePathRelative,
84
83
  key,
85
84
  });
86
- const { dataFilePath, dataFilePathRelative, dataFileChunkName, } = resolvePageDataInfo_1.resolvePageDataInfo({ app, htmlFilePathRelative, key });
85
+ const { dataFilePath, dataFilePathRelative, dataFileChunkName } = (0, resolvePageDataInfo_1.resolvePageDataInfo)({ app, htmlFilePathRelative, key });
87
86
  const page = {
87
+ // page data
88
+ data: {
89
+ key,
90
+ path,
91
+ title,
92
+ lang,
93
+ frontmatter,
94
+ excerpt,
95
+ headers,
96
+ },
88
97
  // base fields
89
98
  key,
90
99
  path,
@@ -103,6 +112,7 @@ const createPage = async (app, optionsRaw) => {
103
112
  pathInferred,
104
113
  pathLocale,
105
114
  permalink,
115
+ routeMeta,
106
116
  slug,
107
117
  // file info
108
118
  filePath,
@@ -116,8 +126,6 @@ const createPage = async (app, optionsRaw) => {
116
126
  htmlFilePath,
117
127
  htmlFilePathRelative,
118
128
  };
119
- // resolve page data
120
- page.data = await resolvePageData_1.resolvePageData({ app, page });
121
129
  return page;
122
130
  };
123
131
  exports.createPage = createPage;
@@ -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';