@vuepress/core 2.0.0-beta.49 → 2.0.0-beta.50-pre.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 (131) hide show
  1. package/dist/index.d.ts +850 -0
  2. package/dist/index.js +1050 -0
  3. package/package.json +29 -10
  4. package/lib/app/appInit.d.ts +0 -7
  5. package/lib/app/appInit.js +0 -27
  6. package/lib/app/appPrepare.d.ts +0 -10
  7. package/lib/app/appPrepare.js +0 -39
  8. package/lib/app/appUse.d.ts +0 -2
  9. package/lib/app/appUse.js +0 -28
  10. package/lib/app/createBaseApp.d.ts +0 -5
  11. package/lib/app/createBaseApp.js +0 -46
  12. package/lib/app/createBuildApp.d.ts +0 -5
  13. package/lib/app/createBuildApp.js +0 -13
  14. package/lib/app/createDevApp.d.ts +0 -5
  15. package/lib/app/createDevApp.js +0 -13
  16. package/lib/app/index.d.ts +0 -17
  17. package/lib/app/index.js +0 -33
  18. package/lib/app/prepare/index.d.ts +0 -8
  19. package/lib/app/prepare/index.js +0 -24
  20. package/lib/app/prepare/prepareClientConfigs.d.ts +0 -5
  21. package/lib/app/prepare/prepareClientConfigs.js +0 -22
  22. package/lib/app/prepare/prepareLayoutComponents.d.ts +0 -5
  23. package/lib/app/prepare/prepareLayoutComponents.js +0 -20
  24. package/lib/app/prepare/preparePageComponent.d.ts +0 -5
  25. package/lib/app/prepare/preparePageComponent.js +0 -16
  26. package/lib/app/prepare/preparePageData.d.ts +0 -5
  27. package/lib/app/prepare/preparePageData.js +0 -31
  28. package/lib/app/prepare/preparePagesComponents.d.ts +0 -5
  29. package/lib/app/prepare/preparePagesComponents.js +0 -24
  30. package/lib/app/prepare/preparePagesData.d.ts +0 -5
  31. package/lib/app/prepare/preparePagesData.js +0 -20
  32. package/lib/app/prepare/preparePagesRoutes.d.ts +0 -5
  33. package/lib/app/prepare/preparePagesRoutes.js +0 -48
  34. package/lib/app/prepare/prepareSiteData.d.ts +0 -5
  35. package/lib/app/prepare/prepareSiteData.js +0 -31
  36. package/lib/app/resolveAppDir.d.ts +0 -9
  37. package/lib/app/resolveAppDir.js +0 -32
  38. package/lib/app/resolveAppEnv.d.ts +0 -5
  39. package/lib/app/resolveAppEnv.js +0 -12
  40. package/lib/app/resolveAppMarkdown.d.ts +0 -6
  41. package/lib/app/resolveAppMarkdown.js +0 -16
  42. package/lib/app/resolveAppOptions.d.ts +0 -5
  43. package/lib/app/resolveAppOptions.js +0 -45
  44. package/lib/app/resolveAppPages.d.ts +0 -5
  45. package/lib/app/resolveAppPages.js +0 -31
  46. package/lib/app/resolveAppSiteData.d.ts +0 -7
  47. package/lib/app/resolveAppSiteData.js +0 -17
  48. package/lib/app/resolveAppVersion.d.ts +0 -4
  49. package/lib/app/resolveAppVersion.js +0 -10
  50. package/lib/app/resolveAppWriteTemp.d.ts +0 -5
  51. package/lib/app/resolveAppWriteTemp.js +0 -21
  52. package/lib/app/resolvePluginObject.d.ts +0 -5
  53. package/lib/app/resolvePluginObject.js +0 -9
  54. package/lib/app/resolveThemeInfo.d.ts +0 -5
  55. package/lib/app/resolveThemeInfo.js +0 -31
  56. package/lib/app/resolveThemeLayouts.d.ts +0 -5
  57. package/lib/app/resolveThemeLayouts.js +0 -25
  58. package/lib/app/setupAppThemeAndPlugins.d.ts +0 -5
  59. package/lib/app/setupAppThemeAndPlugins.js +0 -21
  60. package/lib/index.d.ts +0 -4
  61. package/lib/index.js +0 -20
  62. package/lib/page/createPage.d.ts +0 -2
  63. package/lib/page/createPage.js +0 -118
  64. package/lib/page/index.d.ts +0 -15
  65. package/lib/page/index.js +0 -31
  66. package/lib/page/inferPagePath.d.ts +0 -11
  67. package/lib/page/inferPagePath.js +0 -27
  68. package/lib/page/renderPageContent.d.ts +0 -21
  69. package/lib/page/renderPageContent.js +0 -28
  70. package/lib/page/resolvePageComponentInfo.d.ts +0 -13
  71. package/lib/page/resolvePageComponentInfo.js +0 -19
  72. package/lib/page/resolvePageDataInfo.d.ts +0 -13
  73. package/lib/page/resolvePageDataInfo.js +0 -18
  74. package/lib/page/resolvePageDate.d.ts +0 -10
  75. package/lib/page/resolvePageDate.js +0 -45
  76. package/lib/page/resolvePageFileContent.d.ts +0 -8
  77. package/lib/page/resolvePageFileContent.js +0 -23
  78. package/lib/page/resolvePageFilePath.d.ts +0 -11
  79. package/lib/page/resolvePageFilePath.js +0 -24
  80. package/lib/page/resolvePageHtmlInfo.d.ts +0 -11
  81. package/lib/page/resolvePageHtmlInfo.js +0 -18
  82. package/lib/page/resolvePageKey.d.ts +0 -6
  83. package/lib/page/resolvePageKey.js +0 -9
  84. package/lib/page/resolvePageLang.d.ts +0 -9
  85. package/lib/page/resolvePageLang.js +0 -14
  86. package/lib/page/resolvePagePath.d.ts +0 -9
  87. package/lib/page/resolvePagePath.js +0 -19
  88. package/lib/page/resolvePagePermalink.d.ts +0 -12
  89. package/lib/page/resolvePagePermalink.js +0 -41
  90. package/lib/page/resolvePageRouteMeta.d.ts +0 -7
  91. package/lib/page/resolvePageRouteMeta.js +0 -8
  92. package/lib/page/resolvePageSlug.d.ts +0 -6
  93. package/lib/page/resolvePageSlug.js +0 -17
  94. package/lib/pluginApi/createHookQueue.d.ts +0 -5
  95. package/lib/pluginApi/createHookQueue.js +0 -42
  96. package/lib/pluginApi/createPluginApi.d.ts +0 -2
  97. package/lib/pluginApi/createPluginApi.js +0 -16
  98. package/lib/pluginApi/createPluginApiHooks.d.ts +0 -2
  99. package/lib/pluginApi/createPluginApiHooks.js +0 -23
  100. package/lib/pluginApi/createPluginApiRegisterHooks.d.ts +0 -2
  101. package/lib/pluginApi/createPluginApiRegisterHooks.js +0 -42
  102. package/lib/pluginApi/index.d.ts +0 -6
  103. package/lib/pluginApi/index.js +0 -22
  104. package/lib/pluginApi/normalizeClientConfigFileHook.d.ts +0 -5
  105. package/lib/pluginApi/normalizeClientConfigFileHook.js +0 -19
  106. package/lib/pluginApi/normalizeReturnObjectHook.d.ts +0 -5
  107. package/lib/pluginApi/normalizeReturnObjectHook.js +0 -9
  108. package/lib/types/app/app.d.ts +0 -98
  109. package/lib/types/app/app.js +0 -2
  110. package/lib/types/app/index.d.ts +0 -3
  111. package/lib/types/app/index.js +0 -19
  112. package/lib/types/app/options.d.ts +0 -84
  113. package/lib/types/app/options.js +0 -2
  114. package/lib/types/app/utils.d.ts +0 -36
  115. package/lib/types/app/utils.js +0 -2
  116. package/lib/types/bundler.d.ts +0 -13
  117. package/lib/types/bundler.js +0 -2
  118. package/lib/types/index.d.ts +0 -8
  119. package/lib/types/index.js +0 -22
  120. package/lib/types/page.d.ts +0 -144
  121. package/lib/types/page.js +0 -2
  122. package/lib/types/plugin.d.ts +0 -29
  123. package/lib/types/plugin.js +0 -2
  124. package/lib/types/pluginApi/hooks.d.ts +0 -72
  125. package/lib/types/pluginApi/hooks.js +0 -2
  126. package/lib/types/pluginApi/index.d.ts +0 -2
  127. package/lib/types/pluginApi/index.js +0 -18
  128. package/lib/types/pluginApi/pluginApi.d.ts +0 -23
  129. package/lib/types/pluginApi/pluginApi.js +0 -2
  130. package/lib/types/theme.d.ts +0 -61
  131. package/lib/types/theme.js +0 -2
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveAppDir = exports.createAppDirFunction = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- /**
6
- * Create directory util function
7
- */
8
- const createAppDirFunction = (baseDir) => {
9
- return (...args) => utils_1.path.resolve(baseDir, ...args);
10
- };
11
- exports.createAppDirFunction = createAppDirFunction;
12
- /**
13
- * Resolve directory utils for vuepress app
14
- */
15
- const resolveAppDir = (options) => {
16
- const cache = (0, exports.createAppDirFunction)(options.cache);
17
- const temp = (0, exports.createAppDirFunction)(options.temp);
18
- const source = (0, exports.createAppDirFunction)(options.source);
19
- const dest = (0, exports.createAppDirFunction)(options.dest);
20
- const publicDir = (0, exports.createAppDirFunction)(options.public);
21
- // @vuepress/client
22
- const client = (0, exports.createAppDirFunction)(utils_1.path.resolve(require.resolve('@vuepress/client/package.json'), '..'));
23
- return {
24
- cache,
25
- temp,
26
- source,
27
- dest,
28
- client,
29
- public: publicDir,
30
- };
31
- };
32
- exports.resolveAppDir = resolveAppDir;
@@ -1,5 +0,0 @@
1
- import type { AppEnv, AppOptions } from '../types';
2
- /**
3
- * Resolve environment flags for vuepress app
4
- */
5
- export declare const resolveAppEnv: (options: AppOptions, isBuild: boolean) => AppEnv;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveAppEnv = void 0;
4
- /**
5
- * Resolve environment flags for vuepress app
6
- */
7
- const resolveAppEnv = (options, isBuild) => ({
8
- isBuild,
9
- isDev: !isBuild,
10
- isDebug: options.debug,
11
- });
12
- exports.resolveAppEnv = resolveAppEnv;
@@ -1,6 +0,0 @@
1
- import type { Markdown } from '@vuepress/markdown';
2
- import type { App } from '../types';
3
- /**
4
- * Resolve markdown-it instance for vuepress app
5
- */
6
- export declare const resolveAppMarkdown: (app: App) => Promise<Markdown>;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveAppMarkdown = void 0;
4
- const markdown_1 = require("@vuepress/markdown");
5
- /**
6
- * Resolve markdown-it instance for vuepress app
7
- */
8
- const resolveAppMarkdown = async (app) => {
9
- // plugin hook: extendsMarkdownOptions
10
- await app.pluginApi.hooks.extendsMarkdownOptions.process(app.options.markdown, app);
11
- const markdown = (0, markdown_1.createMarkdown)(app.options.markdown);
12
- // plugin hook: extendsMarkdown
13
- await app.pluginApi.hooks.extendsMarkdown.process(markdown, app);
14
- return markdown;
15
- };
16
- exports.resolveAppMarkdown = resolveAppMarkdown;
@@ -1,5 +0,0 @@
1
- import type { AppConfig, AppOptions } from '../types';
2
- /**
3
- * Create app options with default values
4
- */
5
- export declare const resolveAppOptions: ({ base, lang, title, description, head, locales, source, dest, temp, cache, public: publicDir, host, port, open, templateDev, shouldPreload, shouldPrefetch, templateBuild, bundler, debug, markdown, pagePatterns, permalinkPattern, plugins, theme, }: AppConfig) => AppOptions;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveAppOptions = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- /**
6
- * Create app options with default values
7
- */
8
- const resolveAppOptions = ({
9
- // site config
10
- base = '/', lang = 'en-US', title = '', description = '', head = [], locales = {},
11
- // directory config
12
- source, dest = utils_1.path.resolve(source, '.vuepress/dist'), temp = utils_1.path.resolve(source, '.vuepress/.temp'), cache = utils_1.path.resolve(source, '.vuepress/.cache'), public: publicDir = utils_1.path.resolve(source, '.vuepress/public'),
13
- // dev config
14
- host = '0.0.0.0', port = 8080, open = false, templateDev = utils_1.path.normalize(require.resolve('@vuepress/client/templates/dev.html')),
15
- // build config
16
- shouldPreload = true, shouldPrefetch = true, templateBuild = utils_1.path.normalize(require.resolve('@vuepress/client/templates/build.html')),
17
- // common config
18
- bundler, debug = false, markdown = {}, pagePatterns = ['**/*.md', '!.vuepress', '!node_modules'], permalinkPattern = null, plugins = [], theme, }) => ({
19
- base,
20
- lang,
21
- title,
22
- description,
23
- head,
24
- locales,
25
- source,
26
- dest,
27
- temp,
28
- cache,
29
- public: publicDir,
30
- host,
31
- port,
32
- open,
33
- templateDev,
34
- shouldPreload,
35
- shouldPrefetch,
36
- templateBuild,
37
- bundler,
38
- debug,
39
- markdown,
40
- pagePatterns,
41
- permalinkPattern,
42
- plugins,
43
- theme,
44
- });
45
- exports.resolveAppOptions = resolveAppOptions;
@@ -1,5 +0,0 @@
1
- import type { App, Page } from '../types';
2
- /**
3
- * Resolve pages for vuepress app
4
- */
5
- export declare const resolveAppPages: (app: App) => Promise<Page[]>;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveAppPages = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- const page_1 = require("../page");
6
- const log = (0, utils_1.debug)('vuepress:core/app');
7
- /**
8
- * Resolve pages for vuepress app
9
- */
10
- const resolveAppPages = async (app) => {
11
- log('resolveAppPages start');
12
- // resolve page absolute file paths according to the page patterns
13
- const pageFilePaths = await (0, utils_1.globby)(app.options.pagePatterns, {
14
- absolute: true,
15
- cwd: app.dir.source(),
16
- });
17
- // create pages from files
18
- const pages = await Promise.all(pageFilePaths.map((filePath) => (0, page_1.createPage)(app, { filePath })));
19
- // if there is no 404 page, add one
20
- if (!pages.some((page) => page.path === '/404.html')) {
21
- pages.push(await (0, page_1.createPage)(app, {
22
- path: '/404.html',
23
- frontmatter: {
24
- layout: '404',
25
- },
26
- }));
27
- }
28
- log('resolveAppPages finish');
29
- return pages;
30
- };
31
- exports.resolveAppPages = resolveAppPages;
@@ -1,7 +0,0 @@
1
- import type { AppOptions, SiteData } from '../types';
2
- /**
3
- * Resolve site data for vuepress app
4
- *
5
- * Site data will also be used in client
6
- */
7
- export declare const resolveAppSiteData: (options: AppOptions) => SiteData;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveAppSiteData = void 0;
4
- /**
5
- * Resolve site data for vuepress app
6
- *
7
- * Site data will also be used in client
8
- */
9
- const resolveAppSiteData = (options) => ({
10
- base: options.base,
11
- lang: options.lang,
12
- title: options.title,
13
- description: options.description,
14
- head: options.head,
15
- locales: options.locales,
16
- });
17
- exports.resolveAppSiteData = resolveAppSiteData;
@@ -1,4 +0,0 @@
1
- /**
2
- * Resolve version of vuepress app
3
- */
4
- export declare const resolveAppVersion: () => string;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveAppVersion = void 0;
4
- /**
5
- * Resolve version of vuepress app
6
- */
7
- const resolveAppVersion = () => {
8
- return require('../../package.json').version;
9
- };
10
- exports.resolveAppVersion = resolveAppVersion;
@@ -1,5 +0,0 @@
1
- import type { AppDir, AppWriteTemp } from '../types';
2
- /**
3
- * Resolve write temp file util for vuepress app
4
- */
5
- export declare const resolveAppWriteTemp: (dir: AppDir) => AppWriteTemp;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveAppWriteTemp = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- /**
6
- * Resolve write temp file util for vuepress app
7
- */
8
- const resolveAppWriteTemp = (dir) => {
9
- const tempCache = new Map();
10
- const writeTemp = async (file, content) => {
11
- const filePath = dir.temp(file);
12
- const contentCached = tempCache.get(filePath);
13
- if (contentCached !== content) {
14
- await utils_1.fs.outputFile(filePath, content);
15
- tempCache.set(filePath, content);
16
- }
17
- return filePath;
18
- };
19
- return writeTemp;
20
- };
21
- exports.resolveAppWriteTemp = resolveAppWriteTemp;
@@ -1,5 +0,0 @@
1
- import type { App, Plugin, PluginObject } from '../types';
2
- /**
3
- * Resolve a plugin object according to name / path / module and config
4
- */
5
- export declare const resolvePluginObject: <T extends PluginObject = PluginObject>(app: App, plugin: Plugin<T>) => T;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePluginObject = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- /**
6
- * Resolve a plugin object according to name / path / module and config
7
- */
8
- const resolvePluginObject = (app, plugin) => ((0, shared_1.isFunction)(plugin) ? plugin(app) : plugin);
9
- exports.resolvePluginObject = resolvePluginObject;
@@ -1,5 +0,0 @@
1
- import type { App, Theme, ThemeInfo } from '../types';
2
- /**
3
- * Resolve theme info and its parent theme info
4
- */
5
- export declare const resolveThemeInfo: (app: App, theme: Theme) => ThemeInfo;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveThemeInfo = void 0;
4
- const resolvePluginObject_1 = require("./resolvePluginObject");
5
- const resolveThemeLayouts_1 = require("./resolveThemeLayouts");
6
- /**
7
- * Resolve theme info and its parent theme info
8
- */
9
- const resolveThemeInfo = (app, theme) => {
10
- // resolve current theme info
11
- const themeObject = (0, resolvePluginObject_1.resolvePluginObject)(app, theme);
12
- const themeInfo = {
13
- layouts: (0, resolveThemeLayouts_1.resolveThemeLayouts)(themeObject.layouts),
14
- plugins: [...(themeObject.plugins ?? []), themeObject],
15
- templateBuild: themeObject.templateBuild,
16
- templateDev: themeObject.templateDev,
17
- };
18
- // return if current theme does not have a parent theme
19
- if (!themeObject.extends) {
20
- return themeInfo;
21
- }
22
- // resolve parent theme info recursively
23
- const parentThemeInfo = (0, exports.resolveThemeInfo)(app, themeObject.extends);
24
- return {
25
- layouts: { ...parentThemeInfo.layouts, ...themeInfo.layouts },
26
- plugins: [...parentThemeInfo.plugins, ...themeInfo.plugins],
27
- templateBuild: themeObject.templateBuild ?? parentThemeInfo.templateBuild,
28
- templateDev: themeObject.templateDev ?? parentThemeInfo.templateDev,
29
- };
30
- };
31
- exports.resolveThemeInfo = resolveThemeInfo;
@@ -1,5 +0,0 @@
1
- import type { ThemeObject } from '../types';
2
- /**
3
- * Resolve layouts from `layouts` option
4
- */
5
- export declare const resolveThemeLayouts: (layouts?: ThemeObject['layouts']) => Record<string, string>;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveThemeLayouts = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- const utils_1 = require("@vuepress/utils");
6
- /**
7
- * Resolve layouts from `layouts` option
8
- */
9
- const resolveThemeLayouts = (layouts = {}) => {
10
- // use the layouts component map directly
11
- if ((0, shared_1.isPlainObject)(layouts)) {
12
- return layouts;
13
- }
14
- // resolve the layouts directory
15
- if (!utils_1.fs.pathExistsSync(layouts)) {
16
- throw utils_1.logger.createError(`layouts directory does not exist: ${utils_1.chalk.magenta(layouts)}`);
17
- }
18
- // load all files in layouts directory, then take matched files
19
- // as theme layouts
20
- return Object.fromEntries(utils_1.fs
21
- .readdirSync(layouts)
22
- .filter((file) => /\.(vue|ts|js)$/.test(file))
23
- .map((file) => [utils_1.path.trimExt(file), utils_1.path.resolve(layouts, file)]));
24
- };
25
- exports.resolveThemeLayouts = resolveThemeLayouts;
@@ -1,5 +0,0 @@
1
- import type { App, AppConfig } from '../types';
2
- /**
3
- * Setup theme and plugins for vuepress app
4
- */
5
- export declare const setupAppThemeAndPlugins: (app: App, config: AppConfig) => void;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setupAppThemeAndPlugins = void 0;
4
- const resolveThemeInfo_1 = require("./resolveThemeInfo");
5
- /**
6
- * Setup theme and plugins for vuepress app
7
- */
8
- const setupAppThemeAndPlugins = (app, config) => {
9
- // recursively resolve theme info
10
- const themeInfo = (0, resolveThemeInfo_1.resolveThemeInfo)(app, app.options.theme);
11
- // set up app layouts and templates
12
- app.layouts = themeInfo.layouts;
13
- app.options.templateDev =
14
- config.templateDev ?? themeInfo.templateDev ?? app.options.templateDev;
15
- app.options.templateBuild =
16
- config.templateBuild ?? themeInfo.templateBuild ?? app.options.templateBuild;
17
- [...themeInfo.plugins, ...app.options.plugins]
18
- .flat()
19
- .forEach((plugin) => app.use(plugin));
20
- };
21
- exports.setupAppThemeAndPlugins = setupAppThemeAndPlugins;
package/lib/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './app';
2
- export * from './page';
3
- export * from './pluginApi';
4
- export * from './types';
package/lib/index.js DELETED
@@ -1,20 +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
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./app"), exports);
18
- __exportStar(require("./page"), exports);
19
- __exportStar(require("./pluginApi"), exports);
20
- __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,118 +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 renderPageContent_1 = require("./renderPageContent");
6
- const resolvePageComponentInfo_1 = require("./resolvePageComponentInfo");
7
- const resolvePageDataInfo_1 = require("./resolvePageDataInfo");
8
- const resolvePageDate_1 = require("./resolvePageDate");
9
- const resolvePageFileContent_1 = require("./resolvePageFileContent");
10
- const resolvePageFilePath_1 = require("./resolvePageFilePath");
11
- const resolvePageHtmlInfo_1 = require("./resolvePageHtmlInfo");
12
- const resolvePageKey_1 = require("./resolvePageKey");
13
- const resolvePageLang_1 = require("./resolvePageLang");
14
- const resolvePagePath_1 = require("./resolvePagePath");
15
- const resolvePagePermalink_1 = require("./resolvePagePermalink");
16
- const resolvePageRouteMeta_1 = require("./resolvePageRouteMeta");
17
- const resolvePageSlug_1 = require("./resolvePageSlug");
18
- const createPage = async (app, options) => {
19
- // plugin hook: extendsPageOptions
20
- await app.pluginApi.hooks.extendsPageOptions.process(options, app);
21
- // resolve page file absolute path and relative path
22
- const { filePath, filePathRelative } = (0, resolvePageFilePath_1.resolvePageFilePath)({
23
- app,
24
- options,
25
- });
26
- // read the raw file content according to the absolute file path
27
- const content = await (0, resolvePageFileContent_1.resolvePageFileContent)({ filePath, options });
28
- // render page content and extract information
29
- const { contentRendered, deps, excerpt, frontmatter, headers, links, sfcBlocks, title, } = await (0, renderPageContent_1.renderPageContent)({
30
- app,
31
- content,
32
- filePath,
33
- filePathRelative,
34
- options,
35
- });
36
- // resolve route meta from frontmatter
37
- const routeMeta = (0, resolvePageRouteMeta_1.resolvePageRouteMeta)({ frontmatter });
38
- // resolve slug from file path
39
- const slug = (0, resolvePageSlug_1.resolvePageSlug)({ filePathRelative });
40
- // resolve date from file path
41
- const date = (0, resolvePageDate_1.resolvePageDate)({ frontmatter, filePathRelative });
42
- // infer page path according to file path
43
- const { pathInferred, pathLocale } = (0, inferPagePath_1.inferPagePath)({ app, filePathRelative });
44
- // resolve language from frontmatter and site options
45
- const lang = (0, resolvePageLang_1.resolvePageLang)({ app, frontmatter, pathLocale });
46
- // resolve page permalink
47
- const permalink = (0, resolvePagePermalink_1.resolvePagePermalink)({
48
- app,
49
- frontmatter,
50
- slug,
51
- date,
52
- pathInferred,
53
- pathLocale,
54
- });
55
- // resolve page path
56
- const path = (0, resolvePagePath_1.resolvePagePath)({ permalink, pathInferred, options });
57
- // resolve page key
58
- const key = (0, resolvePageKey_1.resolvePageKey)({ path });
59
- // resolve page rendered html file path
60
- const { htmlFilePath, htmlFilePathRelative } = (0, resolvePageHtmlInfo_1.resolvePageHtmlInfo)({
61
- app,
62
- path,
63
- });
64
- // resolve page component and extract headers & links
65
- const { componentFilePath, componentFilePathRelative, componentFileChunkName, } = await (0, resolvePageComponentInfo_1.resolvePageComponentInfo)({
66
- app,
67
- htmlFilePathRelative,
68
- key,
69
- });
70
- const { dataFilePath, dataFilePathRelative, dataFileChunkName } = (0, resolvePageDataInfo_1.resolvePageDataInfo)({ app, htmlFilePathRelative, key });
71
- const page = {
72
- // page data
73
- data: {
74
- key,
75
- path,
76
- title,
77
- lang,
78
- frontmatter,
79
- excerpt,
80
- headers,
81
- },
82
- // base fields
83
- key,
84
- path,
85
- title,
86
- lang,
87
- frontmatter,
88
- excerpt,
89
- headers,
90
- // extra fields
91
- content,
92
- contentRendered,
93
- date,
94
- deps,
95
- links,
96
- pathInferred,
97
- pathLocale,
98
- permalink,
99
- routeMeta,
100
- sfcBlocks,
101
- slug,
102
- // file info
103
- filePath,
104
- filePathRelative,
105
- componentFilePath,
106
- componentFilePathRelative,
107
- componentFileChunkName,
108
- dataFilePath,
109
- dataFilePathRelative,
110
- dataFileChunkName,
111
- htmlFilePath,
112
- htmlFilePathRelative,
113
- };
114
- // plugin hook: extendsPage
115
- await app.pluginApi.hooks.extendsPage.process(page, app);
116
- return page;
117
- };
118
- exports.createPage = createPage;
@@ -1,15 +0,0 @@
1
- export * from './createPage';
2
- export * from './inferPagePath';
3
- export * from './renderPageContent';
4
- export * from './resolvePageComponentInfo';
5
- export * from './resolvePageDataInfo';
6
- export * from './resolvePageDate';
7
- export * from './resolvePageFileContent';
8
- export * from './resolvePageFilePath';
9
- export * from './resolvePageHtmlInfo';
10
- export * from './resolvePageKey';
11
- export * from './resolvePageLang';
12
- export * from './resolvePagePath';
13
- export * from './resolvePagePermalink';
14
- export * from './resolvePageRouteMeta';
15
- export * from './resolvePageSlug';
package/lib/page/index.js DELETED
@@ -1,31 +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
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./createPage"), exports);
18
- __exportStar(require("./inferPagePath"), exports);
19
- __exportStar(require("./renderPageContent"), exports);
20
- __exportStar(require("./resolvePageComponentInfo"), exports);
21
- __exportStar(require("./resolvePageDataInfo"), exports);
22
- __exportStar(require("./resolvePageDate"), exports);
23
- __exportStar(require("./resolvePageFileContent"), exports);
24
- __exportStar(require("./resolvePageFilePath"), exports);
25
- __exportStar(require("./resolvePageHtmlInfo"), exports);
26
- __exportStar(require("./resolvePageKey"), exports);
27
- __exportStar(require("./resolvePageLang"), exports);
28
- __exportStar(require("./resolvePagePath"), exports);
29
- __exportStar(require("./resolvePagePermalink"), exports);
30
- __exportStar(require("./resolvePageRouteMeta"), exports);
31
- __exportStar(require("./resolvePageSlug"), 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 = (0, shared_1.ensureLeadingSlash)(filePathRelative)
18
- .replace(/\.md$/, '.html')
19
- .replace(/\/(README|index).html$/i, '/');
20
- // resolve page locale path
21
- const pathLocale = (0, shared_1.resolveLocalePath)(app.siteData.locales, pathInferred);
22
- return {
23
- pathInferred,
24
- pathLocale,
25
- };
26
- };
27
- exports.inferPagePath = inferPagePath;
@@ -1,21 +0,0 @@
1
- import type { MarkdownHeader, MarkdownLink } from '@vuepress/markdown';
2
- import type { App, PageFrontmatter, PageOptions } from '../types';
3
- /**
4
- * Render page content and extract related info
5
- */
6
- export declare const renderPageContent: ({ app, content, filePath, filePathRelative, options, }: {
7
- app: App;
8
- content: string;
9
- filePath: string | null;
10
- filePathRelative: string | null;
11
- options: PageOptions;
12
- }) => Promise<{
13
- contentRendered: string;
14
- deps: string[];
15
- excerpt: string;
16
- frontmatter: PageFrontmatter;
17
- headers: MarkdownHeader[];
18
- links: MarkdownLink[];
19
- sfcBlocks: string[];
20
- title: string;
21
- }>;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderPageContent = void 0;
4
- /**
5
- * Render page content and extract related info
6
- */
7
- const renderPageContent = async ({ app, content, filePath, filePathRelative, options, }) => {
8
- const markdownEnv = {
9
- base: app.options.base,
10
- filePath,
11
- filePathRelative,
12
- frontmatter: { ...options.frontmatter },
13
- };
14
- const contentRendered = app.markdown.render(content, markdownEnv);
15
- /* istanbul ignore next */
16
- const { excerpt = '', frontmatter = {}, headers = [], importedFiles = [], links = [], sfcBlocks = [], title = '', } = markdownEnv;
17
- return {
18
- contentRendered,
19
- deps: importedFiles,
20
- excerpt,
21
- frontmatter,
22
- headers,
23
- links,
24
- sfcBlocks,
25
- title: frontmatter.title ?? title,
26
- };
27
- };
28
- exports.renderPageContent = renderPageContent;