@vuepress/core 2.0.0-beta.6 → 2.0.0-beta.60

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 (152) hide show
  1. package/dist/index.d.ts +825 -0
  2. package/dist/index.js +1006 -0
  3. package/package.json +34 -17
  4. package/CHANGELOG.md +0 -279
  5. package/lib/app/appInit.d.ts +0 -7
  6. package/lib/app/appInit.js +0 -37
  7. package/lib/app/appPrepare.d.ts +0 -10
  8. package/lib/app/appPrepare.js +0 -46
  9. package/lib/app/appUse.d.ts +0 -2
  10. package/lib/app/appUse.js +0 -26
  11. package/lib/app/appUseByConfig.d.ts +0 -2
  12. package/lib/app/appUseByConfig.js +0 -14
  13. package/lib/app/createApp.d.ts +0 -5
  14. package/lib/app/createApp.js +0 -44
  15. package/lib/app/createAppDir.d.ts +0 -9
  16. package/lib/app/createAppDir.js +0 -32
  17. package/lib/app/createAppEnv.d.ts +0 -5
  18. package/lib/app/createAppEnv.js +0 -14
  19. package/lib/app/createAppOptions.d.ts +0 -5
  20. package/lib/app/createAppOptions.js +0 -48
  21. package/lib/app/createAppPages.d.ts +0 -5
  22. package/lib/app/createAppPages.js +0 -36
  23. package/lib/app/createAppSiteData.d.ts +0 -7
  24. package/lib/app/createAppSiteData.js +0 -19
  25. package/lib/app/createAppVersion.d.ts +0 -4
  26. package/lib/app/createAppVersion.js +0 -11
  27. package/lib/app/createAppWriteTemp.d.ts +0 -5
  28. package/lib/app/createAppWriteTemp.js +0 -21
  29. package/lib/app/index.d.ts +0 -16
  30. package/lib/app/index.js +0 -28
  31. package/lib/app/normalizePlugin.d.ts +0 -2
  32. package/lib/app/normalizePlugin.js +0 -19
  33. package/lib/app/normalizePluginConfig.d.ts +0 -2
  34. package/lib/app/normalizePluginConfig.js +0 -18
  35. package/lib/app/prepare/index.d.ts +0 -12
  36. package/lib/app/prepare/index.js +0 -24
  37. package/lib/app/prepare/prepareClientAppEnhances.d.ts +0 -5
  38. package/lib/app/prepare/prepareClientAppEnhances.js +0 -24
  39. package/lib/app/prepare/prepareClientAppRootComponents.d.ts +0 -5
  40. package/lib/app/prepare/prepareClientAppRootComponents.js +0 -24
  41. package/lib/app/prepare/prepareClientAppSetups.d.ts +0 -5
  42. package/lib/app/prepare/prepareClientAppSetups.js +0 -24
  43. package/lib/app/prepare/prepareLayoutComponents.d.ts +0 -5
  44. package/lib/app/prepare/prepareLayoutComponents.js +0 -20
  45. package/lib/app/prepare/preparePageComponent.d.ts +0 -5
  46. package/lib/app/prepare/preparePageComponent.js +0 -10
  47. package/lib/app/prepare/preparePageData.d.ts +0 -5
  48. package/lib/app/prepare/preparePageData.js +0 -37
  49. package/lib/app/prepare/preparePageRoutes.d.ts +0 -5
  50. package/lib/app/prepare/preparePageRoutes.js +0 -57
  51. package/lib/app/prepare/preparePagesComponent.d.ts +0 -5
  52. package/lib/app/prepare/preparePagesComponent.js +0 -23
  53. package/lib/app/prepare/preparePagesData.d.ts +0 -5
  54. package/lib/app/prepare/preparePagesData.js +0 -19
  55. package/lib/app/prepare/preparePagesRoutes.d.ts +0 -5
  56. package/lib/app/prepare/preparePagesRoutes.js +0 -25
  57. package/lib/app/prepare/prepareSiteData.d.ts +0 -5
  58. package/lib/app/prepare/prepareSiteData.js +0 -31
  59. package/lib/app/prepare/resolvePageData.d.ts +0 -5
  60. package/lib/app/prepare/resolvePageData.js +0 -18
  61. package/lib/app/resolveBundler.d.ts +0 -2
  62. package/lib/app/resolveBundler.js +0 -10
  63. package/lib/app/resolvePlugin.d.ts +0 -5
  64. package/lib/app/resolvePlugin.js +0 -20
  65. package/lib/index.d.ts +0 -5
  66. package/lib/index.js +0 -17
  67. package/lib/page/createPage.d.ts +0 -2
  68. package/lib/page/createPage.js +0 -98
  69. package/lib/page/index.d.ts +0 -17
  70. package/lib/page/index.js +0 -29
  71. package/lib/page/inferPagePath.d.ts +0 -11
  72. package/lib/page/inferPagePath.js +0 -27
  73. package/lib/page/resolvePageComponentInfo.d.ts +0 -20
  74. package/lib/page/resolvePageComponentInfo.js +0 -41
  75. package/lib/page/resolvePageContent.d.ts +0 -11
  76. package/lib/page/resolvePageContent.js +0 -31
  77. package/lib/page/resolvePageDataInfo.d.ts +0 -12
  78. package/lib/page/resolvePageDataInfo.js +0 -18
  79. package/lib/page/resolvePageDate.d.ts +0 -10
  80. package/lib/page/resolvePageDate.js +0 -46
  81. package/lib/page/resolvePageExcerpt.d.ts +0 -9
  82. package/lib/page/resolvePageExcerpt.js +0 -15
  83. package/lib/page/resolvePageFileContent.d.ts +0 -8
  84. package/lib/page/resolvePageFileContent.js +0 -24
  85. package/lib/page/resolvePageFilePath.d.ts +0 -11
  86. package/lib/page/resolvePageFilePath.js +0 -29
  87. package/lib/page/resolvePageFrontmatter.d.ts +0 -8
  88. package/lib/page/resolvePageFrontmatter.js +0 -12
  89. package/lib/page/resolvePageKey.d.ts +0 -6
  90. package/lib/page/resolvePageKey.js +0 -9
  91. package/lib/page/resolvePageLang.d.ts +0 -9
  92. package/lib/page/resolvePageLang.js +0 -15
  93. package/lib/page/resolvePagePath.d.ts +0 -9
  94. package/lib/page/resolvePagePath.js +0 -8
  95. package/lib/page/resolvePagePermalink.d.ts +0 -11
  96. package/lib/page/resolvePagePermalink.js +0 -32
  97. package/lib/page/resolvePageRoutesInfo.d.ts +0 -11
  98. package/lib/page/resolvePageRoutesInfo.js +0 -16
  99. package/lib/page/resolvePageSlug.d.ts +0 -6
  100. package/lib/page/resolvePageSlug.js +0 -17
  101. package/lib/page/resolvePageTitle.d.ts +0 -9
  102. package/lib/page/resolvePageTitle.js +0 -26
  103. package/lib/pluginApi/createHookQueue.d.ts +0 -5
  104. package/lib/pluginApi/createHookQueue.js +0 -81
  105. package/lib/pluginApi/createPluginApi.d.ts +0 -2
  106. package/lib/pluginApi/createPluginApi.js +0 -16
  107. package/lib/pluginApi/createPluginApiHooks.d.ts +0 -2
  108. package/lib/pluginApi/createPluginApiHooks.js +0 -24
  109. package/lib/pluginApi/createPluginApiRegisterHooks.d.ts +0 -2
  110. package/lib/pluginApi/createPluginApiRegisterHooks.js +0 -54
  111. package/lib/pluginApi/index.d.ts +0 -6
  112. package/lib/pluginApi/index.js +0 -18
  113. package/lib/pluginApi/normalizeClientFilesHook.d.ts +0 -5
  114. package/lib/pluginApi/normalizeClientFilesHook.js +0 -25
  115. package/lib/pluginApi/normalizeReturnObjectHook.d.ts +0 -5
  116. package/lib/pluginApi/normalizeReturnObjectHook.js +0 -9
  117. package/lib/themeApi/createThemeApi.d.ts +0 -7
  118. package/lib/themeApi/createThemeApi.js +0 -30
  119. package/lib/themeApi/index.d.ts +0 -1
  120. package/lib/themeApi/index.js +0 -13
  121. package/lib/themeApi/resolveThemeInfo.d.ts +0 -2
  122. package/lib/themeApi/resolveThemeInfo.js +0 -34
  123. package/lib/themeApi/resolveThemeLayouts.d.ts +0 -5
  124. package/lib/themeApi/resolveThemeLayouts.js +0 -33
  125. package/lib/types/app/app.d.ts +0 -30
  126. package/lib/types/app/app.js +0 -2
  127. package/lib/types/app/index.d.ts +0 -3
  128. package/lib/types/app/index.js +0 -15
  129. package/lib/types/app/options.d.ts +0 -32
  130. package/lib/types/app/options.js +0 -2
  131. package/lib/types/app/utils.d.ts +0 -29
  132. package/lib/types/app/utils.js +0 -2
  133. package/lib/types/bundler.d.ts +0 -34
  134. package/lib/types/bundler.js +0 -2
  135. package/lib/types/index.d.ts +0 -9
  136. package/lib/types/index.js +0 -19
  137. package/lib/types/page.d.ts +0 -98
  138. package/lib/types/page.js +0 -2
  139. package/lib/types/plugin-api/hooks.d.ts +0 -75
  140. package/lib/types/plugin-api/hooks.js +0 -2
  141. package/lib/types/plugin-api/index.d.ts +0 -2
  142. package/lib/types/plugin-api/index.js +0 -14
  143. package/lib/types/plugin-api/pluginApi.d.ts +0 -23
  144. package/lib/types/plugin-api/pluginApi.js +0 -2
  145. package/lib/types/plugin.d.ts +0 -48
  146. package/lib/types/plugin.js +0 -2
  147. package/lib/types/theme-api/index.d.ts +0 -1
  148. package/lib/types/theme-api/index.js +0 -13
  149. package/lib/types/theme-api/themeApi.d.ts +0 -44
  150. package/lib/types/theme-api/themeApi.js +0 -2
  151. package/lib/types/theme.d.ts +0 -33
  152. package/lib/types/theme.js +0 -2
@@ -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,98 +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 resolvePageKey_1 = require("./resolvePageKey");
14
- const resolvePageLang_1 = require("./resolvePageLang");
15
- const resolvePagePath_1 = require("./resolvePagePath");
16
- const resolvePagePermalink_1 = require("./resolvePagePermalink");
17
- const resolvePageRoutesInfo_1 = require("./resolvePageRoutesInfo");
18
- const resolvePageSlug_1 = require("./resolvePageSlug");
19
- const resolvePageTitle_1 = require("./resolvePageTitle");
20
- const createPage = async (app, options) => {
21
- // resolve page file absolute path and relative path
22
- const { filePath, filePathRelative } = resolvePageFilePath_1.resolvePageFilePath({
23
- app,
24
- options,
25
- });
26
- // read the raw file content according to the absolute file path
27
- const contentRaw = await resolvePageFileContent_1.resolvePageFileContent({ filePath, options });
28
- // resolve content & frontmatter & raw excerpt from raw content
29
- const { content, frontmatterRaw, excerptRaw } = resolvePageContent_1.resolvePageContent({
30
- contentRaw,
31
- });
32
- // resolve frontmatter from raw frontmatter and page options
33
- const frontmatter = resolvePageFrontmatter_1.resolvePageFrontmatter({ frontmatterRaw, options });
34
- // resolve excerpt from raw excerpt
35
- const excerpt = resolvePageExcerpt_1.resolvePageExcerpt({ excerptRaw, app, filePathRelative });
36
- // resolve slug from file path
37
- const slug = resolvePageSlug_1.resolvePageSlug({ filePathRelative });
38
- // resolve date from file path
39
- const date = resolvePageDate_1.resolvePageDate({ frontmatter, filePathRelative });
40
- // infer page path according to file path
41
- const { pathInferred, pathLocale } = inferPagePath_1.inferPagePath({ app, filePathRelative });
42
- // resolve language from frontmatter and site options
43
- const lang = resolvePageLang_1.resolvePageLang({ app, frontmatter, pathLocale });
44
- // resolve page permalink
45
- const permalink = resolvePagePermalink_1.resolvePagePermalink({
46
- frontmatter,
47
- slug,
48
- date,
49
- pathInferred,
50
- pathLocale,
51
- });
52
- // resolve page path
53
- const path = resolvePagePath_1.resolvePagePath({ permalink, pathInferred, options });
54
- // resolve path key
55
- const key = resolvePageKey_1.resolvePageKey({ path });
56
- // resolve page component and extract headers & links
57
- const { headers, links, componentFilePath, componentFilePathRelative, componentFileContent, componentFileChunkName, } = await resolvePageComponentInfo_1.resolvePageComponentInfo({
58
- app,
59
- content,
60
- filePathRelative,
61
- path,
62
- key,
63
- });
64
- const { dataFilePath, dataFilePathRelative, dataFileChunkName, } = resolvePageDataInfo_1.resolvePageDataInfo({ app, key });
65
- const { routesFilePath, routesFilePathRelative } = resolvePageRoutesInfo_1.resolvePageRoutesInfo({
66
- app,
67
- key,
68
- });
69
- // resolve title from frontmatter and headers
70
- const title = resolvePageTitle_1.resolvePageTitle({ content, frontmatter, headers });
71
- return {
72
- key,
73
- path,
74
- pathInferred,
75
- pathLocale,
76
- filePath,
77
- filePathRelative,
78
- componentFilePath,
79
- componentFilePathRelative,
80
- componentFileContent,
81
- componentFileChunkName,
82
- dataFilePath,
83
- dataFilePathRelative,
84
- dataFileChunkName,
85
- routesFilePath,
86
- routesFilePathRelative,
87
- title,
88
- content,
89
- frontmatter,
90
- excerpt,
91
- headers,
92
- links,
93
- slug,
94
- date,
95
- lang,
96
- };
97
- };
98
- exports.createPage = createPage;
@@ -1,17 +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 './resolvePageKey';
12
- export * from './resolvePageLang';
13
- export * from './resolvePagePath';
14
- export * from './resolvePagePermalink';
15
- export * from './resolvePageRoutesInfo';
16
- export * from './resolvePageSlug';
17
- export * from './resolvePageTitle';
package/lib/page/index.js DELETED
@@ -1,29 +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("./resolvePageKey"), exports);
24
- __exportStar(require("./resolvePageLang"), exports);
25
- __exportStar(require("./resolvePagePath"), exports);
26
- __exportStar(require("./resolvePagePermalink"), exports);
27
- __exportStar(require("./resolvePageRoutesInfo"), exports);
28
- __exportStar(require("./resolvePageSlug"), exports);
29
- __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 { path } from '@vuepress/utils';
3
- import type { App } from '../types';
4
- /**
5
- * Resolve page component and related info
6
- */
7
- export declare const resolvePageComponentInfo: ({ app, content, filePathRelative, path: routePath, key, }: {
8
- app: App;
9
- content: string;
10
- filePathRelative: string | null;
11
- path: string;
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,41 +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, filePathRelative, path: routePath, key, }) => {
9
- var _a;
10
- const markdownEnv = {
11
- base: app.options.base,
12
- filePathRelative,
13
- };
14
- const rendered = app.markdown.render(content, markdownEnv);
15
- const { headers = [], links = [], hoistedTags = [] } = markdownEnv;
16
- // TODO: links check
17
- // resolve component file content
18
- // take the rendered markdown content as <template>
19
- // hoist `<script>`, `<style>` and other custom blocks
20
- const componentFileContent = [
21
- // if the `<template>` block is empty, vue will print a runtime warning
22
- // during development, so here we add a whitespace to temporarily avoid
23
- // the warning
24
- // @see https://github.com/vuejs/vue-next/issues/2463
25
- `<template>${rendered || ' '}</template>`,
26
- ...hoistedTags,
27
- ].join('\n\n');
28
- // resolve component file path
29
- const componentFilePathRelative = utils_1.path.join('pages', (_a = filePathRelative === null || filePathRelative === void 0 ? void 0 : filePathRelative.replace(/\.md$/, '.vue')) !== null && _a !== void 0 ? _a : `${routePath || key}.vue`);
30
- const componentFilePath = app.dir.temp(componentFilePathRelative);
31
- const componentFileChunkName = key;
32
- return {
33
- headers,
34
- links,
35
- componentFilePath,
36
- componentFilePathRelative,
37
- componentFileContent,
38
- componentFileChunkName,
39
- };
40
- };
41
- 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,31 +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
- const { data, content,
18
- /* istanbul ignore next */
19
- excerpt = '', } = matter(contentRaw, {
20
- excerpt_separator: '<!-- more -->',
21
- engines: {
22
- toml: toml.parse.bind(toml),
23
- },
24
- });
25
- return {
26
- content,
27
- frontmatterRaw: data,
28
- excerptRaw: excerpt,
29
- };
30
- };
31
- 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,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageDataInfo = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- /**
6
- * Resolve page data file path
7
- */
8
- const resolvePageDataInfo = ({ app, key, }) => {
9
- const dataFilePathRelative = utils_1.path.join(`internal/pageData/${key}.js`);
10
- const dataFilePath = app.dir.temp(dataFilePathRelative);
11
- const dataFileChunkName = key;
12
- return {
13
- dataFilePath,
14
- dataFilePathRelative,
15
- dataFileChunkName,
16
- };
17
- };
18
- 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,9 +0,0 @@
1
- import type { App } from '../types';
2
- /**
3
- * Resolve page excerpt from raw excerpt
4
- */
5
- export declare const resolvePageExcerpt: ({ excerptRaw, app, filePathRelative, }: {
6
- excerptRaw: string;
7
- app: App;
8
- filePathRelative: string | null;
9
- }) => string;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageExcerpt = void 0;
4
- /**
5
- * Resolve page excerpt from raw excerpt
6
- */
7
- const resolvePageExcerpt = ({ excerptRaw, app, filePathRelative, }) => {
8
- const markdownEnv = {
9
- base: app.options.base,
10
- filePathRelative,
11
- };
12
- const html = app.markdown.render(excerptRaw, markdownEnv);
13
- return html;
14
- };
15
- exports.resolvePageExcerpt = resolvePageExcerpt;
@@ -1,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
- };
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageFilePath = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- /**
6
- * Resolve absolute and relative path of page file
7
- */
8
- const resolvePageFilePath = ({ app, options: { filePath }, }) => {
9
- // empty file path
10
- if (!filePath) {
11
- return {
12
- filePath: null,
13
- filePathRelative: null,
14
- };
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
- };
22
- }
23
- // relative file path
24
- return {
25
- filePath: app.dir.source(filePath),
26
- filePathRelative: filePath,
27
- };
28
- };
29
- exports.resolvePageFilePath = resolvePageFilePath;
@@ -1,8 +0,0 @@
1
- import type { PageFrontmatter, PageOptions } from '../types';
2
- /**
3
- * Resolve page frontmatter from user frontmatter and options frontmatter
4
- */
5
- export declare const resolvePageFrontmatter: ({ frontmatterRaw, options, }: {
6
- frontmatterRaw: PageFrontmatter;
7
- options: PageOptions;
8
- }) => PageFrontmatter;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageFrontmatter = void 0;
4
- /**
5
- * Resolve page frontmatter from user frontmatter and options frontmatter
6
- */
7
- const resolvePageFrontmatter = ({ frontmatterRaw, options, }) => ({
8
- // raw frontmatter take priority over options frontmatter
9
- ...options.frontmatter,
10
- ...frontmatterRaw,
11
- });
12
- exports.resolvePageFrontmatter = resolvePageFrontmatter;