@vuepress/core 2.0.0-beta.26 → 2.0.0-beta.32

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 (86) hide show
  1. package/lib/app/appInit.js +6 -5
  2. package/lib/app/appPrepare.js +11 -11
  3. package/lib/app/appUse.js +4 -4
  4. package/lib/app/createBaseApp.js +24 -26
  5. package/lib/app/createBuildApp.d.ts +1 -1
  6. package/lib/app/createBuildApp.js +2 -2
  7. package/lib/app/createDevApp.d.ts +1 -1
  8. package/lib/app/createDevApp.js +2 -2
  9. package/lib/app/index.d.ts +9 -9
  10. package/lib/app/index.js +9 -9
  11. package/lib/app/normalizePluginConfig.d.ts +1 -1
  12. package/lib/app/normalizePluginConfig.js +1 -1
  13. package/lib/app/prepare/preparePagesRoutes.js +5 -5
  14. package/lib/app/{createAppDir.d.ts → resolveAppDir.d.ts} +2 -2
  15. package/lib/app/resolveAppDir.js +32 -0
  16. package/lib/app/resolveAppEnv.d.ts +5 -0
  17. package/lib/app/resolveAppEnv.js +12 -0
  18. package/lib/app/resolveAppMarkdown.d.ts +6 -0
  19. package/lib/app/resolveAppMarkdown.js +16 -0
  20. package/lib/app/resolveAppOptions.d.ts +5 -0
  21. package/lib/app/{createAppOptions.js → resolveAppOptions.js} +7 -7
  22. package/lib/app/resolveAppPages.d.ts +5 -0
  23. package/lib/app/resolveAppPages.js +39 -0
  24. package/lib/app/resolveAppSiteData.d.ts +7 -0
  25. package/lib/app/{createAppSiteData.js → resolveAppSiteData.js} +4 -4
  26. package/lib/app/resolveAppVersion.d.ts +4 -0
  27. package/lib/app/resolveAppVersion.js +10 -0
  28. package/lib/app/resolveAppWriteTemp.d.ts +5 -0
  29. package/lib/app/{createAppWriteTemp.js → resolveAppWriteTemp.js} +4 -4
  30. package/lib/app/resolveBundler.js +1 -1
  31. package/lib/app/resolvePluginModule.js +2 -2
  32. package/lib/app/resolvePluginObject.d.ts +5 -0
  33. package/lib/app/resolvePluginObject.js +22 -0
  34. package/lib/app/resolvePluginsFromConfig.d.ts +1 -1
  35. package/lib/app/resolvePluginsFromConfig.js +4 -4
  36. package/lib/app/resolveThemeInfo.d.ts +2 -2
  37. package/lib/app/resolveThemeInfo.js +10 -7
  38. package/lib/app/resolveThemeLayouts.js +1 -1
  39. package/lib/app/resolveThemeObject.d.ts +5 -0
  40. package/lib/app/resolveThemeObject.js +22 -0
  41. package/lib/page/createPage.d.ts +1 -1
  42. package/lib/page/createPage.js +32 -24
  43. package/lib/page/index.d.ts +1 -2
  44. package/lib/page/index.js +1 -2
  45. package/lib/page/inferPagePath.js +2 -2
  46. package/lib/page/resolvePageContent.js +1 -1
  47. package/lib/page/resolvePageDate.d.ts +1 -1
  48. package/lib/page/resolvePageDate.js +5 -5
  49. package/lib/page/resolvePageFileContent.js +2 -2
  50. package/lib/page/resolvePageHtmlInfo.js +1 -1
  51. package/lib/page/resolvePageKey.js +1 -1
  52. package/lib/page/resolvePageLang.js +1 -1
  53. package/lib/page/resolvePagePath.js +1 -1
  54. package/lib/page/resolvePagePermalink.js +3 -3
  55. package/lib/page/resolvePageRouteMeta.d.ts +7 -0
  56. package/lib/page/resolvePageRouteMeta.js +8 -0
  57. package/lib/pluginApi/createHookQueue.js +3 -3
  58. package/lib/pluginApi/createPluginApi.js +2 -2
  59. package/lib/pluginApi/createPluginApiHooks.js +14 -14
  60. package/lib/pluginApi/createPluginApiRegisterHooks.js +5 -5
  61. package/lib/pluginApi/normalizeClientFilesHook.js +2 -2
  62. package/lib/pluginApi/normalizeReturnObjectHook.js +1 -1
  63. package/lib/types/app/app.d.ts +17 -15
  64. package/lib/types/app/options.d.ts +36 -25
  65. package/lib/types/index.d.ts +1 -1
  66. package/lib/types/page.d.ts +9 -3
  67. package/lib/types/pluginApi/hooks.d.ts +6 -7
  68. package/package.json +6 -6
  69. package/lib/app/createAppDir.js +0 -32
  70. package/lib/app/createAppEnv.d.ts +0 -5
  71. package/lib/app/createAppEnv.js +0 -12
  72. package/lib/app/createAppOptions.d.ts +0 -5
  73. package/lib/app/createAppPages.d.ts +0 -5
  74. package/lib/app/createAppPages.js +0 -31
  75. package/lib/app/createAppSiteData.d.ts +0 -7
  76. package/lib/app/createAppVersion.d.ts +0 -4
  77. package/lib/app/createAppVersion.js +0 -10
  78. package/lib/app/createAppWriteTemp.d.ts +0 -5
  79. package/lib/app/resolvePlugin.d.ts +0 -5
  80. package/lib/app/resolvePlugin.js +0 -22
  81. package/lib/app/resolveTheme.d.ts +0 -5
  82. package/lib/app/resolveTheme.js +0 -22
  83. package/lib/page/resolvePageData.d.ts +0 -8
  84. package/lib/page/resolvePageData.js +0 -23
  85. package/lib/page/resolvePageOptions.d.ts +0 -8
  86. package/lib/page/resolvePageOptions.js +0 -15
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolvePluginObject = void 0;
4
+ const shared_1 = require("@vuepress/shared");
5
+ const utils_1 = require("@vuepress/utils");
6
+ const resolvePluginModule_1 = require("./resolvePluginModule");
7
+ /**
8
+ * Resolve a plugin object according to name / path / module and config
9
+ */
10
+ const resolvePluginObject = (app, plugin, pluginConfig = {}) => {
11
+ const pluginModule = (0, shared_1.isString)(plugin)
12
+ ? (0, resolvePluginModule_1.resolvePluginModule)(plugin)
13
+ : plugin;
14
+ if (pluginModule === null) {
15
+ throw utils_1.logger.createError(`plugin is not found: ${utils_1.chalk.magenta(plugin)}`);
16
+ }
17
+ const pluginObject = (0, shared_1.isFunction)(pluginModule)
18
+ ? pluginModule(pluginConfig, app)
19
+ : pluginModule;
20
+ return pluginObject;
21
+ };
22
+ exports.resolvePluginObject = resolvePluginObject;
@@ -1,5 +1,5 @@
1
1
  import type { App, PluginConfig, PluginObject } from '../types';
2
2
  /**
3
- * Resolve plugins from plugin config array
3
+ * Resolve plugin objects from plugin config array
4
4
  */
5
5
  export declare const resolvePluginsFromConfig: (app: App, plugins?: PluginConfig[]) => PluginObject[];
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolvePluginsFromConfig = void 0;
4
4
  const normalizePluginConfig_1 = require("./normalizePluginConfig");
5
- const resolvePlugin_1 = require("./resolvePlugin");
5
+ const resolvePluginObject_1 = require("./resolvePluginObject");
6
6
  /**
7
- * Resolve plugins from plugin config array
7
+ * Resolve plugin objects 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, resolvePluginObject_1.resolvePluginObject)(app, plugin, config === true ? {} : config));
13
13
  }
14
14
  return prev;
15
15
  }, []);
@@ -1,5 +1,5 @@
1
- import type { App, ThemeInfo } from '../types';
1
+ import type { App, ThemeConfig, ThemeInfo } from '../types';
2
2
  /**
3
3
  * Resolve theme info and its parent theme info
4
4
  */
5
- export declare const resolveThemeInfo: (app: App, themeName: string) => ThemeInfo;
5
+ export declare const resolveThemeInfo: (app: App, theme: string, themeConfig: ThemeConfig) => ThemeInfo;
@@ -2,24 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveThemeInfo = void 0;
4
4
  const resolvePluginsFromConfig_1 = require("./resolvePluginsFromConfig");
5
- const resolveTheme_1 = require("./resolveTheme");
6
5
  const resolveThemeLayouts_1 = require("./resolveThemeLayouts");
6
+ const resolveThemeObject_1 = require("./resolveThemeObject");
7
7
  /**
8
8
  * Resolve theme info and its parent theme info
9
9
  */
10
- const resolveThemeInfo = (app, themeName) => {
10
+ const resolveThemeInfo = (app, theme, themeConfig) => {
11
11
  // resolve current theme info
12
- const theme = resolveTheme_1.resolveTheme(app, themeName);
12
+ const themeObject = (0, resolveThemeObject_1.resolveThemeObject)(app, theme, themeConfig);
13
13
  const themeInfo = {
14
- layouts: resolveThemeLayouts_1.resolveThemeLayouts(theme.layouts),
15
- plugins: [theme, ...resolvePluginsFromConfig_1.resolvePluginsFromConfig(app, theme.plugins)],
14
+ layouts: (0, resolveThemeLayouts_1.resolveThemeLayouts)(themeObject.layouts),
15
+ plugins: [
16
+ ...(0, resolvePluginsFromConfig_1.resolvePluginsFromConfig)(app, themeObject.plugins),
17
+ themeObject,
18
+ ],
16
19
  };
17
20
  // return if current theme does not have a parent theme
18
- if (!theme.extends) {
21
+ if (!themeObject.extends) {
19
22
  return themeInfo;
20
23
  }
21
24
  // resolve parent theme info recursively
22
- const parentThemeInfo = exports.resolveThemeInfo(app, theme.extends);
25
+ const parentThemeInfo = (0, exports.resolveThemeInfo)(app, themeObject.extends, themeConfig);
23
26
  return {
24
27
  layouts: { ...parentThemeInfo.layouts, ...themeInfo.layouts },
25
28
  plugins: [...parentThemeInfo.plugins, ...themeInfo.plugins],
@@ -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
@@ -0,0 +1,5 @@
1
+ import type { App, ThemeConfig, ThemeObject } from '../types';
2
+ /**
3
+ * Resolve a theme object according to the theme name
4
+ */
5
+ export declare const resolveThemeObject: (app: App, theme: string, themeConfig: ThemeConfig) => ThemeObject;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveThemeObject = void 0;
4
+ const shared_1 = require("@vuepress/shared");
5
+ const utils_1 = require("@vuepress/utils");
6
+ const resolvePluginObject_1 = require("./resolvePluginObject");
7
+ /**
8
+ * Resolve a theme object according to the theme name
9
+ */
10
+ const resolveThemeObject = (app, theme, themeConfig) => {
11
+ // resolve theme entry according to theme name
12
+ const themeEntry = (0, utils_1.requireResolve)(utils_1.path.isAbsolute(theme)
13
+ ? theme
14
+ : (0, shared_1.normalizePackageName)(theme, 'vuepress', 'theme'));
15
+ if (themeEntry === null) {
16
+ throw utils_1.logger.createError(`theme is not found: ${utils_1.chalk.magenta(theme)}`);
17
+ }
18
+ // resolve theme object from theme entry
19
+ const themeObject = (0, resolvePluginObject_1.resolvePluginObject)(app, themeEntry, themeConfig);
20
+ return themeObject;
21
+ };
22
+ exports.resolveThemeObject = resolveThemeObject;
@@ -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>;
@@ -6,7 +6,6 @@ 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 resolvePageData_1 = require("./resolvePageData");
10
9
  const resolvePageDataInfo_1 = require("./resolvePageDataInfo");
11
10
  const resolvePageDate_1 = require("./resolvePageDate");
12
11
  const resolvePageFileContent_1 = require("./resolvePageFileContent");
@@ -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';
package/lib/page/index.js CHANGED
@@ -17,7 +17,6 @@ __exportStar(require("./renderPageExcerpt"), exports);
17
17
  __exportStar(require("./resolvePageComponentInfo"), exports);
18
18
  __exportStar(require("./resolvePageContent"), exports);
19
19
  __exportStar(require("./resolvePageDataInfo"), exports);
20
- __exportStar(require("./resolvePageData"), exports);
21
20
  __exportStar(require("./resolvePageDate"), exports);
22
21
  __exportStar(require("./resolvePageFileContent"), exports);
23
22
  __exportStar(require("./resolvePageFilePath"), exports);
@@ -25,7 +24,7 @@ __exportStar(require("./resolvePageFrontmatter"), exports);
25
24
  __exportStar(require("./resolvePageHtmlInfo"), exports);
26
25
  __exportStar(require("./resolvePageKey"), exports);
27
26
  __exportStar(require("./resolvePageLang"), exports);
28
- __exportStar(require("./resolvePageOptions"), exports);
29
27
  __exportStar(require("./resolvePagePath"), exports);
30
28
  __exportStar(require("./resolvePagePermalink"), exports);
29
+ __exportStar(require("./resolvePageRouteMeta"), exports);
31
30
  __exportStar(require("./resolvePageSlug"), exports);
@@ -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,
@@ -15,7 +15,7 @@ const resolvePageContent = ({ contentRaw, }) => {
15
15
  };
16
16
  }
17
17
  /* istanbul ignore next */
18
- const { data, content, excerpt = '' } = matter(contentRaw, {
18
+ const { data, content, excerpt = '', } = matter(contentRaw, {
19
19
  excerpt_separator: '<!-- more -->',
20
20
  engines: {
21
21
  toml: toml.parse.bind(toml),
@@ -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
@@ -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;
@@ -12,7 +12,7 @@ const resolvePagePath = ({ permalink, pathInferred, options, }) => {
12
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;
@@ -0,0 +1,7 @@
1
+ import type { PageFrontmatter } from '../types';
2
+ /**
3
+ * Resolve page route meta
4
+ */
5
+ export declare const resolvePageRouteMeta: ({ frontmatter, }: {
6
+ frontmatter: PageFrontmatter;
7
+ }) => Record<string, unknown>;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolvePageRouteMeta = void 0;
4
+ /**
5
+ * Resolve page route meta
6
+ */
7
+ const resolvePageRouteMeta = ({ frontmatter, }) => { var _a; return (_a = frontmatter.routeMeta) !== null && _a !== void 0 ? _a : {}; };
8
+ exports.resolvePageRouteMeta = resolvePageRouteMeta;
@@ -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'),
11
- // page hooks
12
- extendsPageOptions: createHookQueue_1.createHookQueue('extendsPageOptions'),
13
- extendsPageData: createHookQueue_1.createHookQueue('extendsPageData'),
14
- // markdown hooks
15
- extendsMarkdown: createHookQueue_1.createHookQueue('extendsMarkdown'),
7
+ onInitialized: (0, createHookQueue_1.createHookQueue)('onInitialized'),
8
+ onPrepared: (0, createHookQueue_1.createHookQueue)('onPrepared'),
9
+ onWatched: (0, createHookQueue_1.createHookQueue)('onWatched'),
10
+ onGenerated: (0, createHookQueue_1.createHookQueue)('onGenerated'),
11
+ // extends hooks
12
+ extendsMarkdownOptions: (0, createHookQueue_1.createHookQueue)('extendsMarkdownOptions'),
13
+ extendsMarkdown: (0, createHookQueue_1.createHookQueue)('extendsMarkdown'),
14
+ extendsPageOptions: (0, createHookQueue_1.createHookQueue)('extendsPageOptions'),
15
+ extendsPage: (0, createHookQueue_1.createHookQueue)('extendsPage'),
16
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;
@@ -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;