@vuepress/core 2.0.0-beta.9 → 2.0.0-rc.1

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 (156) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +12 -0
  3. package/dist/index.d.ts +845 -0
  4. package/dist/index.js +1039 -0
  5. package/package.json +36 -19
  6. package/CHANGELOG.md +0 -338
  7. package/lib/app/appInit.d.ts +0 -7
  8. package/lib/app/appInit.js +0 -26
  9. package/lib/app/appPrepare.d.ts +0 -10
  10. package/lib/app/appPrepare.js +0 -46
  11. package/lib/app/appUse.d.ts +0 -2
  12. package/lib/app/appUse.js +0 -28
  13. package/lib/app/appUseByConfig.d.ts +0 -2
  14. package/lib/app/appUseByConfig.js +0 -11
  15. package/lib/app/createApp.d.ts +0 -5
  16. package/lib/app/createApp.js +0 -55
  17. package/lib/app/createAppDir.d.ts +0 -9
  18. package/lib/app/createAppDir.js +0 -32
  19. package/lib/app/createAppEnv.d.ts +0 -5
  20. package/lib/app/createAppEnv.js +0 -14
  21. package/lib/app/createAppOptions.d.ts +0 -5
  22. package/lib/app/createAppOptions.js +0 -47
  23. package/lib/app/createAppPages.d.ts +0 -5
  24. package/lib/app/createAppPages.js +0 -36
  25. package/lib/app/createAppSiteData.d.ts +0 -7
  26. package/lib/app/createAppSiteData.js +0 -19
  27. package/lib/app/createAppVersion.d.ts +0 -4
  28. package/lib/app/createAppVersion.js +0 -10
  29. package/lib/app/createAppWriteTemp.d.ts +0 -5
  30. package/lib/app/createAppWriteTemp.js +0 -21
  31. package/lib/app/index.d.ts +0 -16
  32. package/lib/app/index.js +0 -28
  33. package/lib/app/normalizePlugin.d.ts +0 -2
  34. package/lib/app/normalizePlugin.js +0 -17
  35. package/lib/app/normalizePluginConfig.d.ts +0 -2
  36. package/lib/app/normalizePluginConfig.js +0 -15
  37. package/lib/app/prepare/index.d.ts +0 -12
  38. package/lib/app/prepare/index.js +0 -24
  39. package/lib/app/prepare/prepareClientAppEnhances.d.ts +0 -5
  40. package/lib/app/prepare/prepareClientAppEnhances.js +0 -24
  41. package/lib/app/prepare/prepareClientAppRootComponents.d.ts +0 -5
  42. package/lib/app/prepare/prepareClientAppRootComponents.js +0 -24
  43. package/lib/app/prepare/prepareClientAppSetups.d.ts +0 -5
  44. package/lib/app/prepare/prepareClientAppSetups.js +0 -24
  45. package/lib/app/prepare/prepareLayoutComponents.d.ts +0 -5
  46. package/lib/app/prepare/prepareLayoutComponents.js +0 -20
  47. package/lib/app/prepare/preparePageComponent.d.ts +0 -5
  48. package/lib/app/prepare/preparePageComponent.js +0 -10
  49. package/lib/app/prepare/preparePageData.d.ts +0 -5
  50. package/lib/app/prepare/preparePageData.js +0 -37
  51. package/lib/app/prepare/preparePageRoutes.d.ts +0 -5
  52. package/lib/app/prepare/preparePageRoutes.js +0 -57
  53. package/lib/app/prepare/preparePagesComponent.d.ts +0 -5
  54. package/lib/app/prepare/preparePagesComponent.js +0 -23
  55. package/lib/app/prepare/preparePagesData.d.ts +0 -5
  56. package/lib/app/prepare/preparePagesData.js +0 -19
  57. package/lib/app/prepare/preparePagesRoutes.d.ts +0 -5
  58. package/lib/app/prepare/preparePagesRoutes.js +0 -25
  59. package/lib/app/prepare/prepareSiteData.d.ts +0 -5
  60. package/lib/app/prepare/prepareSiteData.js +0 -31
  61. package/lib/app/prepare/resolvePageData.d.ts +0 -5
  62. package/lib/app/prepare/resolvePageData.js +0 -18
  63. package/lib/app/resolveBundler.d.ts +0 -2
  64. package/lib/app/resolveBundler.js +0 -10
  65. package/lib/app/resolvePlugin.d.ts +0 -5
  66. package/lib/app/resolvePlugin.js +0 -20
  67. package/lib/index.d.ts +0 -5
  68. package/lib/index.js +0 -17
  69. package/lib/page/createPage.d.ts +0 -2
  70. package/lib/page/createPage.js +0 -112
  71. package/lib/page/index.d.ts +0 -18
  72. package/lib/page/index.js +0 -30
  73. package/lib/page/inferPagePath.d.ts +0 -11
  74. package/lib/page/inferPagePath.js +0 -27
  75. package/lib/page/resolvePageComponentInfo.d.ts +0 -20
  76. package/lib/page/resolvePageComponentInfo.js +0 -38
  77. package/lib/page/resolvePageContent.d.ts +0 -11
  78. package/lib/page/resolvePageContent.js +0 -30
  79. package/lib/page/resolvePageDataInfo.d.ts +0 -12
  80. package/lib/page/resolvePageDataInfo.js +0 -17
  81. package/lib/page/resolvePageDate.d.ts +0 -10
  82. package/lib/page/resolvePageDate.js +0 -46
  83. package/lib/page/resolvePageExcerpt.d.ts +0 -10
  84. package/lib/page/resolvePageExcerpt.js +0 -16
  85. package/lib/page/resolvePageFileContent.d.ts +0 -8
  86. package/lib/page/resolvePageFileContent.js +0 -24
  87. package/lib/page/resolvePageFilePath.d.ts +0 -11
  88. package/lib/page/resolvePageFilePath.js +0 -29
  89. package/lib/page/resolvePageFrontmatter.d.ts +0 -8
  90. package/lib/page/resolvePageFrontmatter.js +0 -12
  91. package/lib/page/resolvePageHtmlInfo.d.ts +0 -11
  92. package/lib/page/resolvePageHtmlInfo.js +0 -18
  93. package/lib/page/resolvePageKey.d.ts +0 -6
  94. package/lib/page/resolvePageKey.js +0 -9
  95. package/lib/page/resolvePageLang.d.ts +0 -9
  96. package/lib/page/resolvePageLang.js +0 -15
  97. package/lib/page/resolvePagePath.d.ts +0 -9
  98. package/lib/page/resolvePagePath.js +0 -19
  99. package/lib/page/resolvePagePermalink.d.ts +0 -11
  100. package/lib/page/resolvePagePermalink.js +0 -32
  101. package/lib/page/resolvePageRoutesInfo.d.ts +0 -11
  102. package/lib/page/resolvePageRoutesInfo.js +0 -15
  103. package/lib/page/resolvePageSlug.d.ts +0 -6
  104. package/lib/page/resolvePageSlug.js +0 -17
  105. package/lib/page/resolvePageTitle.d.ts +0 -9
  106. package/lib/page/resolvePageTitle.js +0 -26
  107. package/lib/pluginApi/createHookQueue.d.ts +0 -5
  108. package/lib/pluginApi/createHookQueue.js +0 -81
  109. package/lib/pluginApi/createPluginApi.d.ts +0 -2
  110. package/lib/pluginApi/createPluginApi.js +0 -16
  111. package/lib/pluginApi/createPluginApiHooks.d.ts +0 -2
  112. package/lib/pluginApi/createPluginApiHooks.js +0 -24
  113. package/lib/pluginApi/createPluginApiRegisterHooks.d.ts +0 -2
  114. package/lib/pluginApi/createPluginApiRegisterHooks.js +0 -54
  115. package/lib/pluginApi/index.d.ts +0 -6
  116. package/lib/pluginApi/index.js +0 -18
  117. package/lib/pluginApi/normalizeClientFilesHook.d.ts +0 -5
  118. package/lib/pluginApi/normalizeClientFilesHook.js +0 -28
  119. package/lib/pluginApi/normalizeReturnObjectHook.d.ts +0 -5
  120. package/lib/pluginApi/normalizeReturnObjectHook.js +0 -9
  121. package/lib/themeApi/createThemeApi.d.ts +0 -7
  122. package/lib/themeApi/createThemeApi.js +0 -30
  123. package/lib/themeApi/index.d.ts +0 -3
  124. package/lib/themeApi/index.js +0 -15
  125. package/lib/themeApi/resolveThemeInfo.d.ts +0 -2
  126. package/lib/themeApi/resolveThemeInfo.js +0 -32
  127. package/lib/themeApi/resolveThemeLayouts.d.ts +0 -5
  128. package/lib/themeApi/resolveThemeLayouts.js +0 -32
  129. package/lib/types/app/app.d.ts +0 -30
  130. package/lib/types/app/app.js +0 -2
  131. package/lib/types/app/index.d.ts +0 -3
  132. package/lib/types/app/index.js +0 -15
  133. package/lib/types/app/options.d.ts +0 -31
  134. package/lib/types/app/options.js +0 -2
  135. package/lib/types/app/utils.d.ts +0 -29
  136. package/lib/types/app/utils.js +0 -2
  137. package/lib/types/bundler.d.ts +0 -34
  138. package/lib/types/bundler.js +0 -2
  139. package/lib/types/index.d.ts +0 -9
  140. package/lib/types/index.js +0 -19
  141. package/lib/types/page.d.ts +0 -110
  142. package/lib/types/page.js +0 -2
  143. package/lib/types/plugin.d.ts +0 -48
  144. package/lib/types/plugin.js +0 -2
  145. package/lib/types/pluginApi/hooks.d.ts +0 -75
  146. package/lib/types/pluginApi/hooks.js +0 -2
  147. package/lib/types/pluginApi/index.d.ts +0 -2
  148. package/lib/types/pluginApi/index.js +0 -14
  149. package/lib/types/pluginApi/pluginApi.d.ts +0 -23
  150. package/lib/types/pluginApi/pluginApi.js +0 -2
  151. package/lib/types/theme.d.ts +0 -33
  152. package/lib/types/theme.js +0 -2
  153. package/lib/types/themeApi/index.d.ts +0 -1
  154. package/lib/types/themeApi/index.js +0 -13
  155. package/lib/types/themeApi/themeApi.d.ts +0 -44
  156. package/lib/types/themeApi/themeApi.js +0 -2
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.preparePagesRoutes = void 0;
4
- /**
5
- * Generate routes temp file
6
- */
7
- const preparePagesRoutes = async (app) => {
8
- const content = `\
9
- import { Vuepress } from '@vuepress/client/lib/components/Vuepress'
10
- ${app.pages
11
- .map(({ routesFilePath }, index) => `import pageRoutes${index} from '${routesFilePath}'`)
12
- .join('\n')}
13
-
14
- export const pagesRoutes = [
15
- ${app.pages.map((_, index) => ` ...pageRoutes${index},`).join('\n')}
16
- {
17
- name: "404",
18
- path: "/:catchAll(.*)",
19
- component: Vuepress,
20
- },
21
- ]
22
- `;
23
- await app.writeTemp('internal/pagesRoutes.js', content);
24
- };
25
- exports.preparePagesRoutes = preparePagesRoutes;
@@ -1,5 +0,0 @@
1
- import type { App } from '../../types';
2
- /**
3
- * Generate site data temp file
4
- */
5
- export declare const prepareSiteData: (app: App) => Promise<void>;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareSiteData = void 0;
4
- const HMR_CODE = `
5
- if (import.meta.webpackHot) {
6
- import.meta.webpackHot.accept()
7
- if (__VUE_HMR_RUNTIME__.updateSiteData) {
8
- __VUE_HMR_RUNTIME__.updateSiteData(siteData)
9
- }
10
- }
11
-
12
- if (import.meta.hot) {
13
- import.meta.hot.accept(({ siteData }) => {
14
- __VUE_HMR_RUNTIME__.updateSiteData(siteData)
15
- })
16
- }
17
- `;
18
- /**
19
- * Generate site data temp file
20
- */
21
- const prepareSiteData = async (app) => {
22
- let content = `\
23
- export const siteData = ${JSON.stringify(app.siteData, null, 2)}
24
- `;
25
- // inject HMR code
26
- if (app.env.isDev) {
27
- content += HMR_CODE;
28
- }
29
- await app.writeTemp('internal/siteData.js', content);
30
- };
31
- exports.prepareSiteData = prepareSiteData;
@@ -1,5 +0,0 @@
1
- import type { Page, PageData } from '../../types';
2
- /**
3
- * Resolve page data for client usage
4
- */
5
- export declare const resolvePageData: ({ key, path, title, lang, frontmatter, excerpt, headers, }: Page) => PageData;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageData = void 0;
4
- /**
5
- * Resolve page data for client usage
6
- */
7
- const resolvePageData = ({ key, path, title, lang, frontmatter, excerpt, headers, }) => {
8
- return {
9
- key,
10
- path,
11
- title,
12
- lang,
13
- frontmatter,
14
- excerpt,
15
- headers,
16
- };
17
- };
18
- exports.resolvePageData = resolvePageData;
@@ -1,2 +0,0 @@
1
- import type { AppOptions, Bundler } from '../types';
2
- export declare const resolveBundler: ({ bundler, bundlerConfig, }: AppOptions) => Bundler;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveBundler = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- const resolveBundler = ({ bundler, bundlerConfig, }) => {
6
- const bundlerPackage = shared_1.normalizePackageName(bundler, 'vuepress', 'bundler');
7
- const { createBundler } = require(bundlerPackage);
8
- return createBundler(bundlerConfig);
9
- };
10
- exports.resolveBundler = resolveBundler;
@@ -1,5 +0,0 @@
1
- import type { Plugin, PluginObject, PluginOptions } from '../types';
2
- /**
3
- * Resolve a plugin according to name or path
4
- */
5
- export declare const resolvePlugin: <T extends PluginOptions = PluginOptions, U extends PluginObject = PluginObject>(pluginName: string) => Plugin<T, U> | null;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePlugin = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- const utils_1 = require("@vuepress/utils");
6
- /**
7
- * Resolve a plugin according to name or path
8
- */
9
- const resolvePlugin = (pluginName) => {
10
- const pluginEntry = utils_1.path.isAbsolute(pluginName)
11
- ? pluginName
12
- : utils_1.requireResolve(shared_1.normalizePackageName(pluginName, 'vuepress', 'plugin'));
13
- if (pluginEntry === null) {
14
- return null;
15
- }
16
- const required = require(pluginEntry);
17
- // allow default export
18
- return utils_1.hasExportDefault(required) ? required.default : required;
19
- };
20
- exports.resolvePlugin = resolvePlugin;
package/lib/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from './app';
2
- export * from './page';
3
- export * from './pluginApi';
4
- export * from './themeApi';
5
- export * from './types';
package/lib/index.js DELETED
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./app"), exports);
14
- __exportStar(require("./page"), exports);
15
- __exportStar(require("./pluginApi"), exports);
16
- __exportStar(require("./themeApi"), exports);
17
- __exportStar(require("./types"), exports);
@@ -1,2 +0,0 @@
1
- import type { App, Page, PageOptions } from '../types';
2
- export declare const createPage: (app: App, options: PageOptions) => Promise<Page>;
@@ -1,112 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPage = void 0;
4
- const inferPagePath_1 = require("./inferPagePath");
5
- const resolvePageComponentInfo_1 = require("./resolvePageComponentInfo");
6
- const resolvePageContent_1 = require("./resolvePageContent");
7
- const resolvePageDataInfo_1 = require("./resolvePageDataInfo");
8
- const resolvePageDate_1 = require("./resolvePageDate");
9
- const resolvePageExcerpt_1 = require("./resolvePageExcerpt");
10
- const resolvePageFileContent_1 = require("./resolvePageFileContent");
11
- const resolvePageFilePath_1 = require("./resolvePageFilePath");
12
- const resolvePageFrontmatter_1 = require("./resolvePageFrontmatter");
13
- const resolvePageHtmlInfo_1 = require("./resolvePageHtmlInfo");
14
- const resolvePageKey_1 = require("./resolvePageKey");
15
- const resolvePageLang_1 = require("./resolvePageLang");
16
- const resolvePagePath_1 = require("./resolvePagePath");
17
- const resolvePagePermalink_1 = require("./resolvePagePermalink");
18
- const resolvePageRoutesInfo_1 = require("./resolvePageRoutesInfo");
19
- const resolvePageSlug_1 = require("./resolvePageSlug");
20
- const resolvePageTitle_1 = require("./resolvePageTitle");
21
- const createPage = async (app, options) => {
22
- // resolve page file absolute path and relative path
23
- const { filePath, filePathRelative } = resolvePageFilePath_1.resolvePageFilePath({
24
- app,
25
- options,
26
- });
27
- // read the raw file content according to the absolute file path
28
- const contentRaw = await resolvePageFileContent_1.resolvePageFileContent({ filePath, options });
29
- // resolve content & frontmatter & raw excerpt from raw content
30
- const { content, frontmatterRaw, excerptRaw } = resolvePageContent_1.resolvePageContent({
31
- contentRaw,
32
- });
33
- // resolve frontmatter from raw frontmatter and page options
34
- const frontmatter = resolvePageFrontmatter_1.resolvePageFrontmatter({ frontmatterRaw, options });
35
- // resolve excerpt from raw excerpt
36
- const excerpt = resolvePageExcerpt_1.resolvePageExcerpt({
37
- app,
38
- excerptRaw,
39
- filePathRelative,
40
- frontmatter,
41
- });
42
- // resolve slug from file path
43
- const slug = resolvePageSlug_1.resolvePageSlug({ filePathRelative });
44
- // resolve date from file path
45
- const date = resolvePageDate_1.resolvePageDate({ frontmatter, filePathRelative });
46
- // infer page path according to file path
47
- const { pathInferred, pathLocale } = inferPagePath_1.inferPagePath({ app, filePathRelative });
48
- // resolve language from frontmatter and site options
49
- const lang = resolvePageLang_1.resolvePageLang({ app, frontmatter, pathLocale });
50
- // resolve page permalink
51
- const permalink = resolvePagePermalink_1.resolvePagePermalink({
52
- frontmatter,
53
- slug,
54
- date,
55
- pathInferred,
56
- pathLocale,
57
- });
58
- // resolve page path
59
- const path = resolvePagePath_1.resolvePagePath({ permalink, pathInferred, options });
60
- // resolve path key
61
- const key = resolvePageKey_1.resolvePageKey({ path });
62
- // resolve page rendered html file path
63
- const { htmlFilePath, htmlFilePathRelative } = resolvePageHtmlInfo_1.resolvePageHtmlInfo({
64
- app,
65
- path,
66
- });
67
- // resolve page component and extract headers & links
68
- const { headers, links, componentFilePath, componentFilePathRelative, componentFileContent, componentFileChunkName, } = await resolvePageComponentInfo_1.resolvePageComponentInfo({
69
- app,
70
- content,
71
- filePathRelative,
72
- frontmatter,
73
- htmlFilePathRelative,
74
- key,
75
- });
76
- const { dataFilePath, dataFilePathRelative, dataFileChunkName, } = resolvePageDataInfo_1.resolvePageDataInfo({ app, key });
77
- const { routesFilePath, routesFilePathRelative } = resolvePageRoutesInfo_1.resolvePageRoutesInfo({
78
- app,
79
- key,
80
- });
81
- // resolve title from frontmatter and headers
82
- const title = resolvePageTitle_1.resolvePageTitle({ content, frontmatter, headers });
83
- return {
84
- key,
85
- path,
86
- pathInferred,
87
- pathLocale,
88
- filePath,
89
- filePathRelative,
90
- componentFilePath,
91
- componentFilePathRelative,
92
- componentFileContent,
93
- componentFileChunkName,
94
- dataFilePath,
95
- dataFilePathRelative,
96
- dataFileChunkName,
97
- routesFilePath,
98
- routesFilePathRelative,
99
- htmlFilePath,
100
- htmlFilePathRelative,
101
- title,
102
- content,
103
- frontmatter,
104
- excerpt,
105
- headers,
106
- links,
107
- slug,
108
- date,
109
- lang,
110
- };
111
- };
112
- exports.createPage = createPage;
@@ -1,18 +0,0 @@
1
- export * from './createPage';
2
- export * from './inferPagePath';
3
- export * from './resolvePageComponentInfo';
4
- export * from './resolvePageContent';
5
- export * from './resolvePageDataInfo';
6
- export * from './resolvePageDate';
7
- export * from './resolvePageExcerpt';
8
- export * from './resolvePageFileContent';
9
- export * from './resolvePageFilePath';
10
- export * from './resolvePageFrontmatter';
11
- export * from './resolvePageHtmlInfo';
12
- export * from './resolvePageKey';
13
- export * from './resolvePageLang';
14
- export * from './resolvePagePath';
15
- export * from './resolvePagePermalink';
16
- export * from './resolvePageRoutesInfo';
17
- export * from './resolvePageSlug';
18
- export * from './resolvePageTitle';
package/lib/page/index.js DELETED
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./createPage"), exports);
14
- __exportStar(require("./inferPagePath"), exports);
15
- __exportStar(require("./resolvePageComponentInfo"), exports);
16
- __exportStar(require("./resolvePageContent"), exports);
17
- __exportStar(require("./resolvePageDataInfo"), exports);
18
- __exportStar(require("./resolvePageDate"), exports);
19
- __exportStar(require("./resolvePageExcerpt"), exports);
20
- __exportStar(require("./resolvePageFileContent"), exports);
21
- __exportStar(require("./resolvePageFilePath"), exports);
22
- __exportStar(require("./resolvePageFrontmatter"), exports);
23
- __exportStar(require("./resolvePageHtmlInfo"), exports);
24
- __exportStar(require("./resolvePageKey"), exports);
25
- __exportStar(require("./resolvePageLang"), exports);
26
- __exportStar(require("./resolvePagePath"), exports);
27
- __exportStar(require("./resolvePagePermalink"), exports);
28
- __exportStar(require("./resolvePageRoutesInfo"), exports);
29
- __exportStar(require("./resolvePageSlug"), exports);
30
- __exportStar(require("./resolvePageTitle"), exports);
@@ -1,11 +0,0 @@
1
- import type { App } from '../types';
2
- /**
3
- * Infer page path according to file path
4
- */
5
- export declare const inferPagePath: ({ app, filePathRelative, }: {
6
- app: App;
7
- filePathRelative: string | null;
8
- }) => {
9
- pathInferred: string | null;
10
- pathLocale: string;
11
- };
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.inferPagePath = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- /**
6
- * Infer page path according to file path
7
- */
8
- const inferPagePath = ({ app, filePathRelative, }) => {
9
- if (!filePathRelative) {
10
- return {
11
- pathInferred: null,
12
- pathLocale: '/',
13
- };
14
- }
15
- // infer page route path from file path
16
- // foo/bar.md -> /foo/bar.html
17
- const pathInferred = shared_1.ensureLeadingSlash(filePathRelative)
18
- .replace(/\.md$/, '.html')
19
- .replace(/\/(README|index).html$/i, '/');
20
- // resolve page locale path
21
- const pathLocale = shared_1.resolveLocalePath(app.siteData.locales, pathInferred);
22
- return {
23
- pathInferred,
24
- pathLocale,
25
- };
26
- };
27
- exports.inferPagePath = inferPagePath;
@@ -1,20 +0,0 @@
1
- import type { MarkdownHeader, MarkdownLink } from '@vuepress/markdown';
2
- import type { App, PageFrontmatter } from '../types';
3
- /**
4
- * Resolve page component and related info
5
- */
6
- export declare const resolvePageComponentInfo: ({ app, content, frontmatter, filePathRelative, htmlFilePathRelative, key, }: {
7
- app: App;
8
- content: string;
9
- frontmatter: PageFrontmatter;
10
- filePathRelative: string | null;
11
- htmlFilePathRelative: string | null;
12
- key: string;
13
- }) => Promise<{
14
- headers: MarkdownHeader[];
15
- links: MarkdownLink[];
16
- componentFilePath: string;
17
- componentFilePathRelative: string;
18
- componentFileContent: string;
19
- componentFileChunkName: string;
20
- }>;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageComponentInfo = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- /**
6
- * Resolve page component and related info
7
- */
8
- const resolvePageComponentInfo = async ({ app, content, frontmatter, filePathRelative, htmlFilePathRelative, key, }) => {
9
- const markdownEnv = {
10
- base: app.options.base,
11
- filePathRelative,
12
- frontmatter,
13
- };
14
- const rendered = app.markdown.render(content, markdownEnv);
15
- /* istanbul ignore next */
16
- const { headers = [], links = [], hoistedTags = [] } = markdownEnv;
17
- // TODO: links check
18
- // resolve component file content
19
- // take the rendered markdown content as <template>
20
- // hoist `<script>`, `<style>` and other custom blocks
21
- const componentFileContent = [
22
- `<template>${rendered}</template>`,
23
- ...hoistedTags,
24
- ].join('\n\n');
25
- // resolve component file path
26
- const componentFilePathRelative = utils_1.path.join('pages', `${htmlFilePathRelative}.vue`);
27
- const componentFilePath = app.dir.temp(componentFilePathRelative);
28
- const componentFileChunkName = key;
29
- return {
30
- headers,
31
- links,
32
- componentFilePath,
33
- componentFilePathRelative,
34
- componentFileContent,
35
- componentFileChunkName,
36
- };
37
- };
38
- exports.resolvePageComponentInfo = resolvePageComponentInfo;
@@ -1,11 +0,0 @@
1
- import type { PageFrontmatter } from '../types';
2
- /**
3
- * Resolve page content and raw frontmatter & excerpt
4
- */
5
- export declare const resolvePageContent: ({ contentRaw, }: {
6
- contentRaw: string;
7
- }) => {
8
- content: string;
9
- frontmatterRaw: PageFrontmatter;
10
- excerptRaw: string;
11
- };
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageContent = void 0;
4
- const matter = require("gray-matter");
5
- const toml = require("toml");
6
- /**
7
- * Resolve page content and raw frontmatter & excerpt
8
- */
9
- const resolvePageContent = ({ contentRaw, }) => {
10
- if (!contentRaw) {
11
- return {
12
- content: '',
13
- frontmatterRaw: {},
14
- excerptRaw: '',
15
- };
16
- }
17
- /* istanbul ignore next */
18
- const { data, content, excerpt = '' } = matter(contentRaw, {
19
- excerpt_separator: '<!-- more -->',
20
- engines: {
21
- toml: toml.parse.bind(toml),
22
- },
23
- });
24
- return {
25
- content,
26
- frontmatterRaw: data,
27
- excerptRaw: excerpt,
28
- };
29
- };
30
- exports.resolvePageContent = resolvePageContent;
@@ -1,12 +0,0 @@
1
- import type { App } from '../types';
2
- /**
3
- * Resolve page data file path
4
- */
5
- export declare const resolvePageDataInfo: ({ app, key, }: {
6
- app: App;
7
- key: string;
8
- }) => {
9
- dataFilePath: string;
10
- dataFilePathRelative: string;
11
- dataFileChunkName: string;
12
- };
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageDataInfo = void 0;
4
- /**
5
- * Resolve page data file path
6
- */
7
- const resolvePageDataInfo = ({ app, key, }) => {
8
- const dataFilePathRelative = `internal/pageData/${key}.js`;
9
- const dataFilePath = app.dir.temp(dataFilePathRelative);
10
- const dataFileChunkName = key;
11
- return {
12
- dataFilePath,
13
- dataFilePathRelative,
14
- dataFileChunkName,
15
- };
16
- };
17
- exports.resolvePageDataInfo = resolvePageDataInfo;
@@ -1,10 +0,0 @@
1
- import { PageFrontmatter } from '../types';
2
- /**
3
- * Resolve page date according to frontmatter or file path
4
- *
5
- * It will be resolved as 'yyyy-MM-dd' format
6
- */
7
- export declare const resolvePageDate: ({ frontmatter, filePathRelative, }: {
8
- frontmatter: PageFrontmatter;
9
- filePathRelative: string | null;
10
- }) => string;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageDate = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- const utils_1 = require("@vuepress/utils");
6
- const FILENAME_DATE_RE = /^(\d{4})-(\d{1,2})(?:-(\d{1,2}))?-(.*)$/;
7
- const DIRNAME_DATE_RE = /(\d{4})\/(\d{1,2})(?:\/(\d{1,2}))?(\/|$)/;
8
- const DEFAULT_DATE = '0000-00-00';
9
- /**
10
- * Resolve page date according to frontmatter or file path
11
- *
12
- * It will be resolved as 'yyyy-MM-dd' format
13
- */
14
- const resolvePageDate = ({ frontmatter, filePathRelative, }) => {
15
- var _a, _b;
16
- // `frontmatter.date` could be parsed as UTC Date directly
17
- if (frontmatter.date instanceof Date) {
18
- return shared_1.formatDateString([
19
- frontmatter.date.getUTCFullYear(),
20
- frontmatter.date.getUTCMonth() + 1,
21
- frontmatter.date.getUTCDate(),
22
- ].join('-'), DEFAULT_DATE);
23
- }
24
- if (shared_1.isString(frontmatter.date)) {
25
- return shared_1.formatDateString(frontmatter.date, DEFAULT_DATE);
26
- }
27
- if (filePathRelative === null) {
28
- return DEFAULT_DATE;
29
- }
30
- const filename = utils_1.path.parse(filePathRelative).name;
31
- if (filename) {
32
- const matches = filename.match(FILENAME_DATE_RE);
33
- if (matches) {
34
- return shared_1.formatDateString(`${matches[1]}-${matches[2]}-${(_a = matches[3]) !== null && _a !== void 0 ? _a : '01'}`, DEFAULT_DATE);
35
- }
36
- }
37
- const dirname = utils_1.path.dirname(filePathRelative);
38
- if (dirname !== '.') {
39
- const matches = dirname.match(DIRNAME_DATE_RE);
40
- if (matches) {
41
- return shared_1.formatDateString(`${matches[1]}-${matches[2]}-${(_b = matches[3]) !== null && _b !== void 0 ? _b : '01'}`, DEFAULT_DATE);
42
- }
43
- }
44
- return DEFAULT_DATE;
45
- };
46
- exports.resolvePageDate = resolvePageDate;
@@ -1,10 +0,0 @@
1
- import type { App, PageFrontmatter } from '../types';
2
- /**
3
- * Resolve page excerpt from raw excerpt
4
- */
5
- export declare const resolvePageExcerpt: ({ app, excerptRaw, frontmatter, filePathRelative, }: {
6
- app: App;
7
- excerptRaw: string;
8
- frontmatter: PageFrontmatter;
9
- filePathRelative: string | null;
10
- }) => string;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageExcerpt = void 0;
4
- /**
5
- * Resolve page excerpt from raw excerpt
6
- */
7
- const resolvePageExcerpt = ({ app, excerptRaw, frontmatter, filePathRelative, }) => {
8
- const markdownEnv = {
9
- base: app.options.base,
10
- filePathRelative,
11
- frontmatter,
12
- };
13
- const html = app.markdown.render(excerptRaw, markdownEnv);
14
- return html;
15
- };
16
- exports.resolvePageExcerpt = resolvePageExcerpt;
@@ -1,8 +0,0 @@
1
- import type { PageOptions } from '../types';
2
- /**
3
- * Resolve page file content according to filePath or options content
4
- */
5
- export declare const resolvePageFileContent: ({ filePath, options, }: {
6
- filePath: string | null;
7
- options: PageOptions;
8
- }) => Promise<string>;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageFileContent = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- const log = utils_1.debug('vuepress:core/page');
6
- /**
7
- * Resolve page file content according to filePath or options content
8
- */
9
- const resolvePageFileContent = async ({ filePath, options, }) => {
10
- var _a;
11
- if (filePath) {
12
- try {
13
- // read page content from file
14
- const content = await utils_1.fs.readFile(filePath, 'utf-8');
15
- return content;
16
- }
17
- catch (e) {
18
- log(e.message);
19
- }
20
- }
21
- // load raw content from options
22
- return (_a = options.content) !== null && _a !== void 0 ? _a : '';
23
- };
24
- exports.resolvePageFileContent = resolvePageFileContent;
@@ -1,11 +0,0 @@
1
- import type { App, PageOptions } from '../types';
2
- /**
3
- * Resolve absolute and relative path of page file
4
- */
5
- export declare const resolvePageFilePath: ({ app, options: { filePath }, }: {
6
- app: App;
7
- options: PageOptions;
8
- }) => {
9
- filePath: string | null;
10
- filePathRelative: string | null;
11
- };