@vuepress/core 2.0.0-beta.23 → 2.0.0-beta.27

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 (49) hide show
  1. package/lib/app/appInit.js +2 -2
  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/createAppPages.js +6 -5
  6. package/lib/app/createBaseApp.js +17 -17
  7. package/lib/app/createBuildApp.d.ts +1 -1
  8. package/lib/app/createBuildApp.js +2 -2
  9. package/lib/app/createDevApp.d.ts +1 -1
  10. package/lib/app/createDevApp.js +2 -2
  11. package/lib/app/index.d.ts +1 -1
  12. package/lib/app/index.js +1 -1
  13. package/lib/app/normalizePluginConfig.d.ts +1 -1
  14. package/lib/app/normalizePluginConfig.js +1 -1
  15. package/lib/app/prepare/preparePagesRoutes.js +1 -1
  16. package/lib/app/resolveBundler.js +1 -1
  17. package/lib/app/resolvePlugin.js +3 -3
  18. package/lib/app/resolvePluginModule.js +2 -2
  19. package/lib/app/resolvePluginsFromConfig.js +2 -2
  20. package/lib/app/resolveTheme.js +3 -3
  21. package/lib/app/resolveThemeInfo.d.ts +5 -0
  22. package/lib/app/resolveThemeInfo.js +28 -0
  23. package/lib/app/resolveThemeLayouts.js +1 -1
  24. package/lib/page/createPage.js +19 -19
  25. package/lib/page/inferPagePath.js +2 -2
  26. package/lib/page/resolvePageDate.d.ts +1 -1
  27. package/lib/page/resolvePageDate.js +5 -5
  28. package/lib/page/resolvePageFileContent.js +2 -2
  29. package/lib/page/resolvePageFilePath.d.ts +1 -1
  30. package/lib/page/resolvePageFilePath.js +6 -11
  31. package/lib/page/resolvePageHtmlInfo.js +1 -1
  32. package/lib/page/resolvePageKey.js +1 -1
  33. package/lib/page/resolvePageLang.js +1 -1
  34. package/lib/page/resolvePageOptions.js +2 -1
  35. package/lib/page/resolvePagePath.js +2 -2
  36. package/lib/page/resolvePagePermalink.js +3 -3
  37. package/lib/pluginApi/createHookQueue.js +3 -3
  38. package/lib/pluginApi/createPluginApi.js +2 -2
  39. package/lib/pluginApi/createPluginApiHooks.js +12 -12
  40. package/lib/pluginApi/createPluginApiRegisterHooks.js +6 -6
  41. package/lib/pluginApi/normalizeClientFilesHook.js +2 -2
  42. package/lib/pluginApi/normalizeReturnObjectHook.js +1 -1
  43. package/lib/types/app/app.d.ts +1 -1
  44. package/lib/types/index.d.ts +1 -1
  45. package/lib/types/page.d.ts +20 -2
  46. package/lib/types/theme.d.ts +13 -0
  47. package/package.json +6 -6
  48. package/lib/app/resolveThemeApi.d.ts +0 -8
  49. package/lib/app/resolveThemeApi.js +0 -29
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.appInit = void 0;
4
4
  const utils_1 = require("@vuepress/utils");
5
5
  const createAppPages_1 = require("./createAppPages");
6
- const log = utils_1.debug('vuepress:core/app');
6
+ const log = (0, utils_1.debug)('vuepress:core/app');
7
7
  /**
8
8
  * Initialize a vuepress app
9
9
  *
@@ -18,7 +18,7 @@ const appInit = async (app) => {
18
18
  // plugin hook: extendsMarkdown
19
19
  await app.pluginApi.hooks.extendsMarkdown.process(app.markdown, app);
20
20
  // create pages
21
- app.pages = await createAppPages_1.createAppPages(app);
21
+ app.pages = await (0, createAppPages_1.createAppPages)(app);
22
22
  // plugin hook: onInitialized
23
23
  await app.pluginApi.hooks.onInitialized.process(app);
24
24
  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,
@@ -3,21 +3,22 @@ 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((filePath) => (0, page_1.createPage)(app, { filePath })));
18
19
  // if there is no 404 page, add one
19
20
  if (!pages.some((page) => page.path === '/404.html')) {
20
- pages.push(await page_1.createPage(app, {
21
+ pages.push(await (0, page_1.createPage)(app, {
21
22
  path: '/404.html',
22
23
  frontmatter: {
23
24
  layout: '404',
@@ -13,19 +13,19 @@ const createAppSiteData_1 = require("./createAppSiteData");
13
13
  const createAppVersion_1 = require("./createAppVersion");
14
14
  const createAppWriteTemp_1 = require("./createAppWriteTemp");
15
15
  const resolvePluginsFromConfig_1 = require("./resolvePluginsFromConfig");
16
- const resolveThemeApi_1 = require("./resolveThemeApi");
16
+ const resolveThemeInfo_1 = require("./resolveThemeInfo");
17
17
  /**
18
18
  * Create vuepress app
19
19
  */
20
20
  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);
21
+ const version = (0, createAppVersion_1.createAppVersion)();
22
+ const options = (0, createAppOptions_1.createAppOptions)(config);
23
+ const dir = (0, createAppDir_1.createAppDir)(options);
24
+ const env = (0, createAppEnv_1.createAppEnv)(options, isBuild);
25
+ const siteData = (0, createAppSiteData_1.createAppSiteData)(options);
26
+ const markdown = (0, markdown_1.createMarkdown)(options.markdown);
27
+ const pluginApi = (0, pluginApi_1.createPluginApi)();
28
+ const writeTemp = (0, createAppWriteTemp_1.createAppWriteTemp)(dir);
29
29
  const app = {
30
30
  version,
31
31
  options,
@@ -35,16 +35,16 @@ const createBaseApp = (config, isBuild = false) => {
35
35
  markdown,
36
36
  pluginApi,
37
37
  writeTemp,
38
- use: (...args) => appUse_1.appUse(app, ...args),
39
- init: () => appInit_1.appInit(app),
40
- prepare: () => appPrepare_1.appPrepare(app),
38
+ use: (...args) => (0, appUse_1.appUse)(app, ...args),
39
+ init: () => (0, appInit_1.appInit)(app),
40
+ prepare: () => (0, appPrepare_1.appPrepare)(app),
41
41
  };
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;
42
+ // resolve theme info and use theme plugins
43
+ const themeInfo = (0, resolveThemeInfo_1.resolveThemeInfo)(app, options.theme);
44
+ themeInfo.plugins.forEach((plugin) => app.use(plugin));
45
+ app.layouts = themeInfo.layouts;
46
46
  // resolve plugins
47
- const plugins = resolvePluginsFromConfig_1.resolvePluginsFromConfig(app, options.plugins);
47
+ const plugins = (0, resolvePluginsFromConfig_1.resolvePluginsFromConfig)(app, options.plugins);
48
48
  plugins.forEach((plugin) => app.use(plugin));
49
49
  return app;
50
50
  };
@@ -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]
@@ -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
  }
@@ -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
@@ -6,8 +6,8 @@ const renderPageContent_1 = require("./renderPageContent");
6
6
  const renderPageExcerpt_1 = require("./renderPageExcerpt");
7
7
  const resolvePageComponentInfo_1 = require("./resolvePageComponentInfo");
8
8
  const resolvePageContent_1 = require("./resolvePageContent");
9
- const resolvePageDataInfo_1 = require("./resolvePageDataInfo");
10
9
  const resolvePageData_1 = require("./resolvePageData");
10
+ const resolvePageDataInfo_1 = require("./resolvePageDataInfo");
11
11
  const resolvePageDate_1 = require("./resolvePageDate");
12
12
  const resolvePageFileContent_1 = require("./resolvePageFileContent");
13
13
  const resolvePageFilePath_1 = require("./resolvePageFilePath");
@@ -21,22 +21,22 @@ const resolvePagePermalink_1 = require("./resolvePagePermalink");
21
21
  const resolvePageSlug_1 = require("./resolvePageSlug");
22
22
  const createPage = async (app, optionsRaw) => {
23
23
  // resolve page options from raw options
24
- const options = await resolvePageOptions_1.resolvePageOptions({ app, optionsRaw });
24
+ const options = await (0, resolvePageOptions_1.resolvePageOptions)({ app, optionsRaw });
25
25
  // resolve page file absolute path and relative path
26
- const { filePath, filePathRelative } = resolvePageFilePath_1.resolvePageFilePath({
26
+ const { filePath, filePathRelative } = (0, resolvePageFilePath_1.resolvePageFilePath)({
27
27
  app,
28
28
  options,
29
29
  });
30
30
  // read the raw file content according to the absolute file path
31
- const contentRaw = await resolvePageFileContent_1.resolvePageFileContent({ filePath, options });
31
+ const contentRaw = await (0, resolvePageFileContent_1.resolvePageFileContent)({ filePath, options });
32
32
  // resolve content & frontmatter & raw excerpt from raw content
33
- const { content, frontmatterRaw, excerptRaw } = resolvePageContent_1.resolvePageContent({
33
+ const { content, frontmatterRaw, excerptRaw } = (0, resolvePageContent_1.resolvePageContent)({
34
34
  contentRaw,
35
35
  });
36
36
  // resolve frontmatter from raw frontmatter and page options
37
- const frontmatter = resolvePageFrontmatter_1.resolvePageFrontmatter({ frontmatterRaw, options });
37
+ const frontmatter = (0, resolvePageFrontmatter_1.resolvePageFrontmatter)({ frontmatterRaw, options });
38
38
  // render excerpt
39
- const excerpt = renderPageExcerpt_1.renderPageExcerpt({
39
+ const excerpt = (0, renderPageExcerpt_1.renderPageExcerpt)({
40
40
  app,
41
41
  excerptRaw,
42
42
  filePath,
@@ -44,7 +44,7 @@ const createPage = async (app, optionsRaw) => {
44
44
  frontmatter,
45
45
  });
46
46
  // render page content and extract information
47
- const { contentRendered, deps, headers, hoistedTags, links, title, } = await renderPageContent_1.renderPageContent({
47
+ const { contentRendered, deps, headers, hoistedTags, links, title, } = await (0, renderPageContent_1.renderPageContent)({
48
48
  app,
49
49
  content,
50
50
  filePath,
@@ -52,15 +52,15 @@ const createPage = async (app, optionsRaw) => {
52
52
  frontmatter,
53
53
  });
54
54
  // resolve slug from file path
55
- const slug = resolvePageSlug_1.resolvePageSlug({ filePathRelative });
55
+ const slug = (0, resolvePageSlug_1.resolvePageSlug)({ filePathRelative });
56
56
  // resolve date from file path
57
- const date = resolvePageDate_1.resolvePageDate({ frontmatter, filePathRelative });
57
+ const date = (0, resolvePageDate_1.resolvePageDate)({ frontmatter, filePathRelative });
58
58
  // infer page path according to file path
59
- const { pathInferred, pathLocale } = inferPagePath_1.inferPagePath({ app, filePathRelative });
59
+ const { pathInferred, pathLocale } = (0, inferPagePath_1.inferPagePath)({ app, filePathRelative });
60
60
  // resolve language from frontmatter and site options
61
- const lang = resolvePageLang_1.resolvePageLang({ app, frontmatter, pathLocale });
61
+ const lang = (0, resolvePageLang_1.resolvePageLang)({ app, frontmatter, pathLocale });
62
62
  // resolve page permalink
63
- const permalink = resolvePagePermalink_1.resolvePagePermalink({
63
+ const permalink = (0, resolvePagePermalink_1.resolvePagePermalink)({
64
64
  frontmatter,
65
65
  slug,
66
66
  date,
@@ -68,22 +68,22 @@ const createPage = async (app, optionsRaw) => {
68
68
  pathLocale,
69
69
  });
70
70
  // resolve page path
71
- const path = resolvePagePath_1.resolvePagePath({ permalink, pathInferred, options });
71
+ const path = (0, resolvePagePath_1.resolvePagePath)({ permalink, pathInferred, options });
72
72
  // resolve path key
73
- const key = resolvePageKey_1.resolvePageKey({ path });
73
+ const key = (0, resolvePageKey_1.resolvePageKey)({ path });
74
74
  // resolve page rendered html file path
75
- const { htmlFilePath, htmlFilePathRelative } = resolvePageHtmlInfo_1.resolvePageHtmlInfo({
75
+ const { htmlFilePath, htmlFilePathRelative } = (0, resolvePageHtmlInfo_1.resolvePageHtmlInfo)({
76
76
  app,
77
77
  path,
78
78
  });
79
79
  // resolve page component and extract headers & links
80
- const { componentFilePath, componentFilePathRelative, componentFileChunkName, } = await resolvePageComponentInfo_1.resolvePageComponentInfo({
80
+ const { componentFilePath, componentFilePathRelative, componentFileChunkName, } = await (0, resolvePageComponentInfo_1.resolvePageComponentInfo)({
81
81
  app,
82
82
  hoistedTags,
83
83
  htmlFilePathRelative,
84
84
  key,
85
85
  });
86
- const { dataFilePath, dataFilePathRelative, dataFileChunkName, } = resolvePageDataInfo_1.resolvePageDataInfo({ app, htmlFilePathRelative, key });
86
+ const { dataFilePath, dataFilePathRelative, dataFileChunkName, } = (0, resolvePageDataInfo_1.resolvePageDataInfo)({ app, htmlFilePathRelative, key });
87
87
  const page = {
88
88
  // base fields
89
89
  key,
@@ -117,7 +117,7 @@ const createPage = async (app, optionsRaw) => {
117
117
  htmlFilePathRelative,
118
118
  };
119
119
  // resolve page data
120
- page.data = await resolvePageData_1.resolvePageData({ app, page });
120
+ page.data = await (0, resolvePageData_1.resolvePageData)({ app, page });
121
121
  return page;
122
122
  };
123
123
  exports.createPage = createPage;
@@ -14,11 +14,11 @@ const inferPagePath = ({ app, filePathRelative, }) => {
14
14
  }
15
15
  // infer page route path from file path
16
16
  // foo/bar.md -> /foo/bar.html
17
- const pathInferred = shared_1.ensureLeadingSlash(filePathRelative)
17
+ const pathInferred = (0, shared_1.ensureLeadingSlash)(filePathRelative)
18
18
  .replace(/\.md$/, '.html')
19
19
  .replace(/\/(README|index).html$/i, '/');
20
20
  // resolve page locale path
21
- const pathLocale = shared_1.resolveLocalePath(app.siteData.locales, pathInferred);
21
+ const pathLocale = (0, shared_1.resolveLocalePath)(app.siteData.locales, pathInferred);
22
22
  return {
23
23
  pathInferred,
24
24
  pathLocale,
@@ -1,4 +1,4 @@
1
- import { PageFrontmatter } from '../types';
1
+ import type { PageFrontmatter } from '../types';
2
2
  /**
3
3
  * Resolve page date according to frontmatter or file path
4
4
  *
@@ -15,14 +15,14 @@ const resolvePageDate = ({ frontmatter, filePathRelative, }) => {
15
15
  var _a, _b;
16
16
  // `frontmatter.date` could be parsed as UTC Date directly
17
17
  if (frontmatter.date instanceof Date) {
18
- return shared_1.formatDateString([
18
+ return (0, shared_1.formatDateString)([
19
19
  frontmatter.date.getUTCFullYear(),
20
20
  frontmatter.date.getUTCMonth() + 1,
21
21
  frontmatter.date.getUTCDate(),
22
22
  ].join('-'), DEFAULT_DATE);
23
23
  }
24
- if (shared_1.isString(frontmatter.date)) {
25
- return shared_1.formatDateString(frontmatter.date, DEFAULT_DATE);
24
+ if ((0, shared_1.isString)(frontmatter.date)) {
25
+ return (0, shared_1.formatDateString)(frontmatter.date, DEFAULT_DATE);
26
26
  }
27
27
  if (filePathRelative === null) {
28
28
  return DEFAULT_DATE;
@@ -31,14 +31,14 @@ const resolvePageDate = ({ frontmatter, filePathRelative, }) => {
31
31
  if (filename) {
32
32
  const matches = filename.match(FILENAME_DATE_RE);
33
33
  if (matches) {
34
- return shared_1.formatDateString(`${matches[1]}-${matches[2]}-${(_a = matches[3]) !== null && _a !== void 0 ? _a : '01'}`, DEFAULT_DATE);
34
+ return (0, shared_1.formatDateString)(`${matches[1]}-${matches[2]}-${(_a = matches[3]) !== null && _a !== void 0 ? _a : '01'}`, DEFAULT_DATE);
35
35
  }
36
36
  }
37
37
  const dirname = utils_1.path.dirname(filePathRelative);
38
38
  if (dirname !== '.') {
39
39
  const matches = dirname.match(DIRNAME_DATE_RE);
40
40
  if (matches) {
41
- return shared_1.formatDateString(`${matches[1]}-${matches[2]}-${(_b = matches[3]) !== null && _b !== void 0 ? _b : '01'}`, DEFAULT_DATE);
41
+ return (0, shared_1.formatDateString)(`${matches[1]}-${matches[2]}-${(_b = matches[3]) !== null && _b !== void 0 ? _b : '01'}`, DEFAULT_DATE);
42
42
  }
43
43
  }
44
44
  return DEFAULT_DATE;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolvePageFileContent = void 0;
4
4
  const utils_1 = require("@vuepress/utils");
5
- const log = utils_1.debug('vuepress:core/page');
5
+ const log = (0, utils_1.debug)('vuepress:core/page');
6
6
  /**
7
7
  * Resolve page file content according to filePath or options content
8
8
  */
@@ -15,7 +15,7 @@ const resolvePageFileContent = async ({ filePath, options, }) => {
15
15
  return content;
16
16
  }
17
17
  catch (e) {
18
- log(e.message);
18
+ log(e instanceof Error ? e.message : e);
19
19
  }
20
20
  }
21
21
  // load raw content from options
@@ -2,7 +2,7 @@ import type { App, PageOptions } from '../types';
2
2
  /**
3
3
  * Resolve absolute and relative path of page file
4
4
  */
5
- export declare const resolvePageFilePath: ({ app, options: { filePath }, }: {
5
+ export declare const resolvePageFilePath: ({ app, options, }: {
6
6
  app: App;
7
7
  options: PageOptions;
8
8
  }) => {
@@ -5,25 +5,20 @@ const utils_1 = require("@vuepress/utils");
5
5
  /**
6
6
  * Resolve absolute and relative path of page file
7
7
  */
8
- const resolvePageFilePath = ({ app, options: { filePath }, }) => {
8
+ const resolvePageFilePath = ({ app, options, }) => {
9
9
  // empty file path
10
- if (!filePath) {
10
+ if (!options.filePath) {
11
11
  return {
12
12
  filePath: null,
13
13
  filePathRelative: null,
14
14
  };
15
15
  }
16
- // absolute file path
17
- if (utils_1.path.isAbsolute(filePath)) {
18
- return {
19
- filePath,
20
- filePathRelative: utils_1.path.relative(app.dir.source(), filePath),
21
- };
16
+ if (!utils_1.path.isAbsolute(options.filePath)) {
17
+ throw utils_1.logger.createError(`filePath is not absolute file path: ${options.filePath}}`);
22
18
  }
23
- // relative file path
24
19
  return {
25
- filePath: app.dir.source(filePath),
26
- filePathRelative: filePath,
20
+ filePath: options.filePath,
21
+ filePathRelative: utils_1.path.relative(app.dir.source(), options.filePath),
27
22
  };
28
23
  };
29
24
  exports.resolvePageFilePath = resolvePageFilePath;
@@ -8,7 +8,7 @@ const shared_1 = require("@vuepress/shared");
8
8
  const resolvePageHtmlInfo = ({ app, path: pagePath, }) => {
9
9
  // /foo.html -> foo.html
10
10
  // /foo/ -> foo/index.html
11
- const htmlFilePathRelative = shared_1.removeLeadingSlash(decodeURI(pagePath.replace(/\/$/, '/index.html')));
11
+ const htmlFilePathRelative = (0, shared_1.removeLeadingSlash)(decodeURI(pagePath.replace(/\/$/, '/index.html')));
12
12
  const htmlFilePath = app.dir.dest(htmlFilePathRelative);
13
13
  return {
14
14
  htmlFilePath,
@@ -5,5 +5,5 @@ const utils_1 = require("@vuepress/utils");
5
5
  /**
6
6
  * Resolve page key to identify the page
7
7
  */
8
- const resolvePageKey = ({ path }) => `v-${utils_1.hash(path)}`;
8
+ const resolvePageKey = ({ path }) => `v-${(0, utils_1.hash)(path)}`;
9
9
  exports.resolvePageKey = resolvePageKey;
@@ -7,7 +7,7 @@ const shared_1 = require("@vuepress/shared");
7
7
  */
8
8
  const resolvePageLang = ({ app, frontmatter, pathLocale, }) => {
9
9
  var _a, _b;
10
- if (shared_1.isString(frontmatter.lang) && frontmatter.lang) {
10
+ if ((0, shared_1.isString)(frontmatter.lang) && frontmatter.lang) {
11
11
  return frontmatter.lang;
12
12
  }
13
13
  return (_b = (_a = app.siteData.locales[pathLocale]) === null || _a === void 0 ? void 0 : _a.lang) !== null && _b !== void 0 ? _b : app.siteData.lang;
@@ -5,9 +5,10 @@ exports.resolvePageOptions = void 0;
5
5
  * Render page content and extract related info
6
6
  */
7
7
  const resolvePageOptions = async ({ app, optionsRaw, }) => {
8
+ // avoid mutating the original options object provided by user
8
9
  const options = { ...optionsRaw };
9
10
  // plugin hook: extendsPageOptions
10
- const extendsPageOptions = await app.pluginApi.hooks.extendsPageOptions.process(optionsRaw, app);
11
+ const extendsPageOptions = await app.pluginApi.hooks.extendsPageOptions.process(options, app);
11
12
  extendsPageOptions.forEach((item) => Object.assign(options, item));
12
13
  return options;
13
14
  };
@@ -9,10 +9,10 @@ const utils_1 = require("@vuepress/utils");
9
9
  const resolvePagePath = ({ permalink, pathInferred, options, }) => {
10
10
  let pagePath = options.path || permalink || pathInferred;
11
11
  if (!pagePath) {
12
- throw utils_1.logger.createError(`page path is empty, page options: ${JSON.stringify(options)}`);
12
+ throw utils_1.logger.createError(`page path is empty, page options: ${JSON.stringify(options, null, 2)}`);
13
13
  }
14
14
  if (!pagePath.endsWith('.html')) {
15
- pagePath = shared_1.ensureEndingSlash(pagePath);
15
+ pagePath = (0, shared_1.ensureEndingSlash)(pagePath);
16
16
  }
17
17
  return encodeURI(pagePath);
18
18
  };
@@ -9,11 +9,11 @@ const utils_1 = require("@vuepress/utils");
9
9
  const resolvePagePermalink = ({ frontmatter, slug, date, pathInferred, pathLocale, }) => {
10
10
  var _a;
11
11
  // use permalink in frontmatter directly
12
- if (shared_1.isString(frontmatter.permalink)) {
12
+ if ((0, shared_1.isString)(frontmatter.permalink)) {
13
13
  return frontmatter.permalink;
14
14
  }
15
15
  // get permalink pattern from frontmatter or options
16
- const pattern = shared_1.isString(frontmatter.permalinkPattern)
16
+ const pattern = (0, shared_1.isString)(frontmatter.permalinkPattern)
17
17
  ? frontmatter.permalinkPattern
18
18
  : null;
19
19
  if (!pattern) {
@@ -27,6 +27,6 @@ const resolvePagePermalink = ({ frontmatter, slug, date, pathInferred, pathLocal
27
27
  .replace(/:day/, day)
28
28
  .replace(/:slug/, slug)
29
29
  .replace(/:raw/, (_a = pathInferred === null || pathInferred === void 0 ? void 0 : pathInferred.replace(/^\//, '')) !== null && _a !== void 0 ? _a : ''));
30
- return shared_1.ensureLeadingSlash(link);
30
+ return (0, shared_1.ensureLeadingSlash)(link);
31
31
  };
32
32
  exports.resolvePagePermalink = resolvePagePermalink;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createHookQueue = void 0;
4
4
  const utils_1 = require("@vuepress/utils");
5
- const log = utils_1.debug('vuepress:core/plugin-api');
5
+ const log = (0, utils_1.debug)('vuepress:core/plugin-api');
6
6
  /**
7
7
  * Create hook queue for plugin system
8
8
  */
@@ -29,9 +29,9 @@ const createHookQueue = (name) => {
29
29
  results.push(result);
30
30
  }
31
31
  }
32
- catch (error) {
32
+ catch (e) {
33
33
  utils_1.logger.error(`error in hook ${utils_1.chalk.magenta(name)} from ${utils_1.chalk.magenta(item.pluginName)}`);
34
- throw error;
34
+ throw e;
35
35
  }
36
36
  }
37
37
  return results;
@@ -5,8 +5,8 @@ const createPluginApiHooks_1 = require("./createPluginApiHooks");
5
5
  const createPluginApiRegisterHooks_1 = require("./createPluginApiRegisterHooks");
6
6
  const createPluginApi = () => {
7
7
  const plugins = [];
8
- const hooks = createPluginApiHooks_1.createPluginApiHooks();
9
- const registerHooks = createPluginApiRegisterHooks_1.createPluginApiRegisterHooks(plugins, hooks);
8
+ const hooks = (0, createPluginApiHooks_1.createPluginApiHooks)();
9
+ const registerHooks = (0, createPluginApiRegisterHooks_1.createPluginApiRegisterHooks)(plugins, hooks);
10
10
  return {
11
11
  plugins,
12
12
  hooks,
@@ -4,21 +4,21 @@ exports.createPluginApiHooks = void 0;
4
4
  const createHookQueue_1 = require("./createHookQueue");
5
5
  const createPluginApiHooks = () => ({
6
6
  // life cycle hooks
7
- onInitialized: createHookQueue_1.createHookQueue('onInitialized'),
8
- onPrepared: createHookQueue_1.createHookQueue('onPrepared'),
9
- onWatched: createHookQueue_1.createHookQueue('onWatched'),
10
- onGenerated: createHookQueue_1.createHookQueue('onGenerated'),
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
11
  // page hooks
12
- extendsPageOptions: createHookQueue_1.createHookQueue('extendsPageOptions'),
13
- extendsPageData: createHookQueue_1.createHookQueue('extendsPageData'),
12
+ extendsPageOptions: (0, createHookQueue_1.createHookQueue)('extendsPageOptions'),
13
+ extendsPageData: (0, createHookQueue_1.createHookQueue)('extendsPageData'),
14
14
  // markdown hooks
15
- extendsMarkdown: createHookQueue_1.createHookQueue('extendsMarkdown'),
15
+ extendsMarkdown: (0, createHookQueue_1.createHookQueue)('extendsMarkdown'),
16
16
  // client files hooks
17
- clientAppEnhanceFiles: createHookQueue_1.createHookQueue('clientAppEnhanceFiles'),
18
- clientAppRootComponentFiles: createHookQueue_1.createHookQueue('clientAppRootComponentFiles'),
19
- clientAppSetupFiles: createHookQueue_1.createHookQueue('clientAppSetupFiles'),
17
+ clientAppEnhanceFiles: (0, createHookQueue_1.createHookQueue)('clientAppEnhanceFiles'),
18
+ clientAppRootComponentFiles: (0, createHookQueue_1.createHookQueue)('clientAppRootComponentFiles'),
19
+ clientAppSetupFiles: (0, createHookQueue_1.createHookQueue)('clientAppSetupFiles'),
20
20
  // bundler hooks
21
- alias: createHookQueue_1.createHookQueue('alias'),
22
- define: createHookQueue_1.createHookQueue('define'),
21
+ alias: (0, createHookQueue_1.createHookQueue)('alias'),
22
+ define: (0, createHookQueue_1.createHookQueue)('define'),
23
23
  });
24
24
  exports.createPluginApiHooks = createPluginApiHooks;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createPluginApiRegisterHooks = void 0;
4
- const normalizeReturnObjectHook_1 = require("./normalizeReturnObjectHook");
5
4
  const normalizeClientFilesHook_1 = require("./normalizeClientFilesHook");
5
+ const normalizeReturnObjectHook_1 = require("./normalizeReturnObjectHook");
6
6
  const createPluginApiRegisterHooks = (plugins, hooks) => () => {
7
7
  plugins.forEach(({ name: pluginName, alias, define, clientAppEnhanceFiles, clientAppRootComponentFiles, clientAppSetupFiles, ...commonHooks }) => {
8
8
  /**
@@ -11,31 +11,31 @@ const createPluginApiRegisterHooks = (plugins, hooks) => () => {
11
11
  if (alias) {
12
12
  hooks.alias.add({
13
13
  pluginName,
14
- hook: normalizeReturnObjectHook_1.normalizeReturnObjectHook(alias),
14
+ hook: (0, normalizeReturnObjectHook_1.normalizeReturnObjectHook)(alias),
15
15
  });
16
16
  }
17
17
  if (define) {
18
18
  hooks.define.add({
19
19
  pluginName,
20
- hook: normalizeReturnObjectHook_1.normalizeReturnObjectHook(define),
20
+ hook: (0, normalizeReturnObjectHook_1.normalizeReturnObjectHook)(define),
21
21
  });
22
22
  }
23
23
  if (clientAppEnhanceFiles) {
24
24
  hooks.clientAppEnhanceFiles.add({
25
25
  pluginName,
26
- hook: normalizeClientFilesHook_1.normalizeClientFilesHook(clientAppEnhanceFiles),
26
+ hook: (0, normalizeClientFilesHook_1.normalizeClientFilesHook)(clientAppEnhanceFiles),
27
27
  });
28
28
  }
29
29
  if (clientAppRootComponentFiles) {
30
30
  hooks.clientAppRootComponentFiles.add({
31
31
  pluginName,
32
- hook: normalizeClientFilesHook_1.normalizeClientFilesHook(clientAppRootComponentFiles),
32
+ hook: (0, normalizeClientFilesHook_1.normalizeClientFilesHook)(clientAppRootComponentFiles),
33
33
  });
34
34
  }
35
35
  if (clientAppSetupFiles) {
36
36
  hooks.clientAppSetupFiles.add({
37
37
  pluginName,
38
- hook: normalizeClientFilesHook_1.normalizeClientFilesHook(clientAppSetupFiles),
38
+ hook: (0, normalizeClientFilesHook_1.normalizeClientFilesHook)(clientAppSetupFiles),
39
39
  });
40
40
  }
41
41
  /**
@@ -8,8 +8,8 @@ const utils_1 = require("@vuepress/utils");
8
8
  */
9
9
  const normalizeClientFilesHook = (hook) => async (app) => {
10
10
  // resolve clientFiles result
11
- const clientFilesResult = shared_1.isFunction(hook) ? await hook(app) : hook;
12
- const clientFiles = shared_1.isArray(clientFilesResult)
11
+ const clientFilesResult = (0, shared_1.isFunction)(hook) ? await hook(app) : hook;
12
+ const clientFiles = (0, shared_1.isArray)(clientFilesResult)
13
13
  ? clientFilesResult
14
14
  : [clientFilesResult];
15
15
  // filter files that do not exist
@@ -5,5 +5,5 @@ const shared_1 = require("@vuepress/shared");
5
5
  /**
6
6
  * Normalize hook that returns an object
7
7
  */
8
- const normalizeReturnObjectHook = (hook) => async (app) => shared_1.isFunction(hook) ? hook(app) : hook;
8
+ const normalizeReturnObjectHook = (hook) => async (app) => (0, shared_1.isFunction)(hook) ? hook(app) : hook;
9
9
  exports.normalizeReturnObjectHook = normalizeReturnObjectHook;
@@ -1,6 +1,6 @@
1
1
  import type { Markdown } from '@vuepress/markdown';
2
2
  import type { SiteData } from '@vuepress/shared';
3
- import type { BundlerDev, BundlerBuild } from '../bundler';
3
+ import type { BundlerBuild, BundlerDev } from '../bundler';
4
4
  import type { Page } from '../page';
5
5
  import type { Plugin, PluginOptions } from '../plugin';
6
6
  import type { PluginApi } from '../pluginApi';
@@ -1,4 +1,4 @@
1
- import type { HeadConfig, HeadTag, HeadTagEmpty, HeadTagNonEmpty, HeadAttrsConfig, LocaleConfig, LocaleData, PageData, PageFrontmatter, PageHeader, SiteData, SiteLocaleConfig } from '@vuepress/shared';
1
+ import type { HeadAttrsConfig, HeadConfig, HeadTag, HeadTagEmpty, HeadTagNonEmpty, LocaleConfig, LocaleData, PageData, PageFrontmatter, PageHeader, SiteData, SiteLocaleConfig } from '@vuepress/shared';
2
2
  export type { HeadConfig, HeadTag, HeadTagEmpty, HeadTagNonEmpty, HeadAttrsConfig, LocaleConfig, LocaleData, PageData, PageFrontmatter, PageHeader, SiteData, SiteLocaleConfig, };
3
3
  export * from './app';
4
4
  export * from './bundler';
@@ -113,8 +113,26 @@ export interface Page<T extends PageData = PageData> extends PageData {
113
113
  * Options to create vuepress page
114
114
  */
115
115
  export interface PageOptions {
116
- path?: string;
116
+ /**
117
+ * If `filePath` is not set, this option will be used as the raw
118
+ * markdown content of the page.
119
+ *
120
+ * If `filePath` is set, this option will be ignored, while the
121
+ * content of the file will be used.
122
+ */
123
+ content?: string;
124
+ /**
125
+ * Absolute file path of the markdown source file.
126
+ */
117
127
  filePath?: string;
128
+ /**
129
+ * Default frontmatter of the page, which could be overridden by
130
+ * the frontmatter of the markdown content.
131
+ */
118
132
  frontmatter?: PageFrontmatter;
119
- content?: string;
133
+ /**
134
+ * If this option is set, it will be used as the final route path
135
+ * of the page, ignoring the relative path and permalink.
136
+ */
137
+ path?: string;
120
138
  }
@@ -32,3 +32,16 @@ export interface ThemeObject extends PluginObject {
32
32
  * @remark suffix `Config` means this is for user config
33
33
  */
34
34
  export declare type ThemeConfig = Record<string, any>;
35
+ /**
36
+ * Resolved theme info
37
+ */
38
+ export interface ThemeInfo {
39
+ /**
40
+ * Layout components
41
+ */
42
+ layouts: Record<string, string>;
43
+ /**
44
+ * Plugins, including theme itself and plugins used by theme
45
+ */
46
+ plugins: PluginObject[];
47
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/core",
3
- "version": "2.0.0-beta.23",
3
+ "version": "2.0.0-beta.27",
4
4
  "description": "Core package of VuePress",
5
5
  "keywords": [
6
6
  "vuepress",
@@ -26,15 +26,15 @@
26
26
  "clean": "rimraf lib *.tsbuildinfo"
27
27
  },
28
28
  "dependencies": {
29
- "@vuepress/client": "2.0.0-beta.23",
30
- "@vuepress/markdown": "2.0.0-beta.23",
31
- "@vuepress/shared": "2.0.0-beta.23",
32
- "@vuepress/utils": "2.0.0-beta.23",
29
+ "@vuepress/client": "2.0.0-beta.27",
30
+ "@vuepress/markdown": "2.0.0-beta.27",
31
+ "@vuepress/shared": "2.0.0-beta.27",
32
+ "@vuepress/utils": "2.0.0-beta.27",
33
33
  "gray-matter": "^4.0.3",
34
34
  "toml": "^3.0.0"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "a8fde04c51473d9b7aef1a49550f9c8f3483b645"
39
+ "gitHead": "2671a94fe6864e215eb84f318b7e657744a0bc5d"
40
40
  }
@@ -1,8 +0,0 @@
1
- import type { App, PluginObject } from '../types';
2
- /**
3
- * Recursively resolve plugins and layouts of theme and its parent theme
4
- */
5
- export declare const resolveThemeApi: (app: App, themeName: string) => {
6
- layouts: Record<string, string>;
7
- plugins: PluginObject[];
8
- };
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveThemeApi = void 0;
4
- const resolvePluginsFromConfig_1 = require("./resolvePluginsFromConfig");
5
- const resolveTheme_1 = require("./resolveTheme");
6
- const resolveThemeLayouts_1 = require("./resolveThemeLayouts");
7
- /**
8
- * Recursively resolve plugins and layouts of theme and its parent theme
9
- */
10
- const resolveThemeApi = (app, themeName) => {
11
- const theme = resolveTheme_1.resolveTheme(app, themeName);
12
- const themeLayouts = resolveThemeLayouts_1.resolveThemeLayouts(theme.layouts);
13
- const themePlugins = resolvePluginsFromConfig_1.resolvePluginsFromConfig(app, theme.plugins);
14
- if (!theme.extends) {
15
- return {
16
- layouts: themeLayouts,
17
- plugins: [theme, ...themePlugins],
18
- };
19
- }
20
- const parentThemeApi = exports.resolveThemeApi(app, theme.extends);
21
- return {
22
- layouts: {
23
- ...parentThemeApi.layouts,
24
- ...themeLayouts,
25
- },
26
- plugins: [...parentThemeApi.plugins, theme, ...themePlugins],
27
- };
28
- };
29
- exports.resolveThemeApi = resolveThemeApi;