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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/lib/app/appInit.js +6 -5
  2. package/lib/app/appPrepare.js +11 -11
  3. package/lib/app/appUse.js +4 -4
  4. package/lib/app/createBaseApp.js +24 -26
  5. package/lib/app/createBuildApp.d.ts +1 -1
  6. package/lib/app/createBuildApp.js +2 -2
  7. package/lib/app/createDevApp.d.ts +1 -1
  8. package/lib/app/createDevApp.js +2 -2
  9. package/lib/app/index.d.ts +9 -9
  10. package/lib/app/index.js +9 -9
  11. package/lib/app/normalizePluginConfig.d.ts +1 -1
  12. package/lib/app/normalizePluginConfig.js +1 -1
  13. package/lib/app/prepare/preparePagesRoutes.js +5 -5
  14. package/lib/app/{createAppDir.d.ts → resolveAppDir.d.ts} +2 -2
  15. package/lib/app/resolveAppDir.js +32 -0
  16. package/lib/app/resolveAppEnv.d.ts +5 -0
  17. package/lib/app/resolveAppEnv.js +12 -0
  18. package/lib/app/resolveAppMarkdown.d.ts +6 -0
  19. package/lib/app/resolveAppMarkdown.js +16 -0
  20. package/lib/app/resolveAppOptions.d.ts +5 -0
  21. package/lib/app/{createAppOptions.js → resolveAppOptions.js} +7 -7
  22. package/lib/app/resolveAppPages.d.ts +5 -0
  23. package/lib/app/resolveAppPages.js +39 -0
  24. package/lib/app/resolveAppSiteData.d.ts +7 -0
  25. package/lib/app/{createAppSiteData.js → resolveAppSiteData.js} +4 -4
  26. package/lib/app/resolveAppVersion.d.ts +4 -0
  27. package/lib/app/resolveAppVersion.js +10 -0
  28. package/lib/app/resolveAppWriteTemp.d.ts +5 -0
  29. package/lib/app/{createAppWriteTemp.js → resolveAppWriteTemp.js} +4 -4
  30. package/lib/app/resolveBundler.js +1 -1
  31. package/lib/app/resolvePluginModule.js +2 -2
  32. package/lib/app/resolvePluginObject.d.ts +5 -0
  33. package/lib/app/resolvePluginObject.js +22 -0
  34. package/lib/app/resolvePluginsFromConfig.d.ts +1 -1
  35. package/lib/app/resolvePluginsFromConfig.js +4 -4
  36. package/lib/app/resolveThemeInfo.d.ts +2 -2
  37. package/lib/app/resolveThemeInfo.js +10 -7
  38. package/lib/app/resolveThemeLayouts.js +1 -1
  39. package/lib/app/resolveThemeObject.d.ts +5 -0
  40. package/lib/app/resolveThemeObject.js +22 -0
  41. package/lib/page/createPage.d.ts +1 -1
  42. package/lib/page/createPage.js +32 -24
  43. package/lib/page/index.d.ts +1 -2
  44. package/lib/page/index.js +1 -2
  45. package/lib/page/inferPagePath.js +2 -2
  46. package/lib/page/resolvePageContent.js +1 -1
  47. package/lib/page/resolvePageDate.d.ts +1 -1
  48. package/lib/page/resolvePageDate.js +5 -5
  49. package/lib/page/resolvePageFileContent.js +2 -2
  50. package/lib/page/resolvePageHtmlInfo.js +1 -1
  51. package/lib/page/resolvePageKey.js +1 -1
  52. package/lib/page/resolvePageLang.js +1 -1
  53. package/lib/page/resolvePagePath.js +1 -1
  54. package/lib/page/resolvePagePermalink.js +3 -3
  55. package/lib/page/resolvePageRouteMeta.d.ts +7 -0
  56. package/lib/page/resolvePageRouteMeta.js +8 -0
  57. package/lib/pluginApi/createHookQueue.js +3 -3
  58. package/lib/pluginApi/createPluginApi.js +2 -2
  59. package/lib/pluginApi/createPluginApiHooks.js +14 -14
  60. package/lib/pluginApi/createPluginApiRegisterHooks.js +5 -5
  61. package/lib/pluginApi/normalizeClientFilesHook.js +2 -2
  62. package/lib/pluginApi/normalizeReturnObjectHook.js +1 -1
  63. package/lib/types/app/app.d.ts +17 -15
  64. package/lib/types/app/options.d.ts +36 -25
  65. package/lib/types/index.d.ts +1 -1
  66. package/lib/types/page.d.ts +9 -3
  67. package/lib/types/pluginApi/hooks.d.ts +6 -7
  68. package/package.json +6 -6
  69. package/lib/app/createAppDir.js +0 -32
  70. package/lib/app/createAppEnv.d.ts +0 -5
  71. package/lib/app/createAppEnv.js +0 -12
  72. package/lib/app/createAppOptions.d.ts +0 -5
  73. package/lib/app/createAppPages.d.ts +0 -5
  74. package/lib/app/createAppPages.js +0 -31
  75. package/lib/app/createAppSiteData.d.ts +0 -7
  76. package/lib/app/createAppVersion.d.ts +0 -4
  77. package/lib/app/createAppVersion.js +0 -10
  78. package/lib/app/createAppWriteTemp.d.ts +0 -5
  79. package/lib/app/resolvePlugin.d.ts +0 -5
  80. package/lib/app/resolvePlugin.js +0 -22
  81. package/lib/app/resolveTheme.d.ts +0 -5
  82. package/lib/app/resolveTheme.js +0 -22
  83. package/lib/page/resolvePageData.d.ts +0 -8
  84. package/lib/page/resolvePageData.js +0 -23
  85. package/lib/page/resolvePageOptions.d.ts +0 -8
  86. package/lib/page/resolvePageOptions.js +0 -15
@@ -1,6 +1,6 @@
1
1
  import type { Markdown } from '@vuepress/markdown';
2
2
  import type { SiteData } from '@vuepress/shared';
3
- import type { BundlerDev, BundlerBuild } from '../bundler';
3
+ import type { BundlerBuild, BundlerDev } from '../bundler';
4
4
  import type { Page } from '../page';
5
5
  import type { Plugin, PluginOptions } from '../plugin';
6
6
  import type { PluginApi } from '../pluginApi';
@@ -10,14 +10,6 @@ import type { AppDir, AppEnv, AppWriteTemp } from './utils';
10
10
  * Vuepress app
11
11
  */
12
12
  export interface App {
13
- /**
14
- * Version of vuepress core
15
- */
16
- version: string;
17
- /**
18
- * Options that filled all optional fields with a default value
19
- */
20
- options: AppOptions;
21
13
  /**
22
14
  * Directory utils
23
15
  */
@@ -27,17 +19,21 @@ export interface App {
27
19
  */
28
20
  env: AppEnv;
29
21
  /**
30
- * Site data, which will be used in client side
31
- */
32
- siteData: SiteData;
33
- /**
34
- * Markdown-it instance
22
+ * Options that filled all optional fields with a default value
35
23
  */
36
- markdown: Markdown;
24
+ options: AppOptions;
37
25
  /**
38
26
  * Plugin system
39
27
  */
40
28
  pluginApi: PluginApi;
29
+ /**
30
+ * Site data, which will be used in client side
31
+ */
32
+ siteData: SiteData;
33
+ /**
34
+ * Version of vuepress core
35
+ */
36
+ version: string;
41
37
  /**
42
38
  * Write temp file
43
39
  */
@@ -65,6 +61,12 @@ export interface App {
65
61
  * Only available after initialization
66
62
  */
67
63
  layouts: Record<string, string>;
64
+ /**
65
+ * Markdown-it instance.
66
+ *
67
+ * Only available after initialization
68
+ */
69
+ markdown: Markdown;
68
70
  /**
69
71
  * Page objects.
70
72
  *
@@ -1,33 +1,44 @@
1
1
  import type { MarkdownOptions } from '@vuepress/markdown';
2
- import type { SiteLocaleConfig, SiteLocaleData } from '@vuepress/shared';
2
+ import type { SiteData } from '@vuepress/shared';
3
3
  import type { BundlerConfig } from '../bundler';
4
4
  import type { PluginConfig } from '../plugin';
5
5
  import type { ThemeConfig } from '../theme';
6
6
  /**
7
- * Vuepress app options
7
+ * Config to create vuepress app
8
8
  */
9
- export interface AppOptions<T extends ThemeConfig = ThemeConfig, U extends BundlerConfig = BundlerConfig> extends SiteLocaleData {
10
- base: string;
11
- locales: SiteLocaleConfig;
12
- theme: string;
13
- themeConfig: Partial<T>;
14
- bundler: string;
15
- bundlerConfig: Partial<U>;
9
+ export declare type AppConfig<T extends ThemeConfig = ThemeConfig, U extends BundlerConfig = BundlerConfig> = Partial<SiteData> & AppConfigDev & AppConfigBuild & {
10
+ theme?: string;
11
+ themeConfig?: Partial<T>;
12
+ bundler?: string;
13
+ bundlerConfig?: Partial<U>;
16
14
  source: string;
17
- dest: string;
18
- temp: string;
19
- cache: string;
20
- public: string;
21
- markdown: MarkdownOptions;
22
- debug: boolean;
23
- host: string;
24
- port: number;
25
- open: boolean;
26
- pagePatterns: string[];
27
- templateDev: string;
28
- templateSSR: string;
29
- shouldPreload: ((file: string, type: string) => boolean) | boolean;
30
- shouldPrefetch: ((file: string, type: string) => boolean) | boolean;
31
- plugins: PluginConfig[];
15
+ dest?: string;
16
+ temp?: string;
17
+ cache?: string;
18
+ public?: string;
19
+ debug?: boolean;
20
+ pagePatterns?: string[];
21
+ markdown?: MarkdownOptions;
22
+ plugins?: PluginConfig[];
23
+ };
24
+ /**
25
+ * Vuepress app config for dev
26
+ */
27
+ export interface AppConfigDev {
28
+ host?: string;
29
+ port?: number;
30
+ open?: boolean;
31
+ templateDev?: string;
32
32
  }
33
- export declare type AppConfig = Partial<AppOptions> & Pick<AppOptions, 'source'>;
33
+ /**
34
+ * Vuepress app config for build
35
+ */
36
+ export interface AppConfigBuild {
37
+ shouldPreload?: ((file: string, type: string) => boolean) | boolean;
38
+ shouldPrefetch?: ((file: string, type: string) => boolean) | boolean;
39
+ templateBuild?: string;
40
+ }
41
+ /**
42
+ * Vuepress app options
43
+ */
44
+ export declare type AppOptions<T extends ThemeConfig = ThemeConfig, U extends BundlerConfig = BundlerConfig> = Required<AppConfig<T, U>>;
@@ -1,4 +1,4 @@
1
- import type { HeadConfig, HeadTag, HeadTagEmpty, HeadTagNonEmpty, HeadAttrsConfig, LocaleConfig, LocaleData, PageData, PageFrontmatter, PageHeader, SiteData, SiteLocaleConfig } from '@vuepress/shared';
1
+ import type { HeadAttrsConfig, HeadConfig, HeadTag, HeadTagEmpty, HeadTagNonEmpty, LocaleConfig, LocaleData, PageData, PageFrontmatter, PageHeader, SiteData, SiteLocaleConfig } from '@vuepress/shared';
2
2
  export type { HeadConfig, HeadTag, HeadTagEmpty, HeadTagNonEmpty, HeadAttrsConfig, LocaleConfig, LocaleData, PageData, PageFrontmatter, PageHeader, SiteData, SiteLocaleConfig, };
3
3
  export * from './app';
4
4
  export * from './bundler';
@@ -3,11 +3,11 @@ import type { PageData, PageFrontmatter } from '@vuepress/shared';
3
3
  /**
4
4
  * Vuepress Page
5
5
  */
6
- export interface Page<T extends PageData = PageData> extends PageData {
6
+ export declare type Page<ExtraPageData extends Record<any, any> = Record<never, never>, ExtraPageFields extends Record<any, any> = Record<never, never>> = PageData & ExtraPageFields & {
7
7
  /**
8
8
  * Data of the page, which will be available in client code
9
9
  */
10
- data: T;
10
+ data: PageData<ExtraPageData>;
11
11
  /**
12
12
  * Raw Content of the page
13
13
  */
@@ -56,6 +56,12 @@ export interface Page<T extends PageData = PageData> extends PageData {
56
56
  * If the page does not have a permalink, it would be `null`
57
57
  */
58
58
  permalink: string | null;
59
+ /**
60
+ * Custom data to be attached to the page route record of vue-router
61
+ *
62
+ * @see https://next.router.vuejs.org/api/#meta
63
+ */
64
+ routeMeta: Record<string, unknown>;
59
65
  /**
60
66
  * Slug of the page
61
67
  */
@@ -108,7 +114,7 @@ export interface Page<T extends PageData = PageData> extends PageData {
108
114
  * Rendered html file path relative to dest directory
109
115
  */
110
116
  htmlFilePathRelative: string;
111
- }
117
+ };
112
118
  /**
113
119
  * Options to create vuepress page
114
120
  */
@@ -1,4 +1,4 @@
1
- import type { Markdown } from '@vuepress/markdown';
1
+ import type { Markdown, MarkdownOptions } from '@vuepress/markdown';
2
2
  import type { App } from '../app';
3
3
  import type { Page, PageOptions } from '../page';
4
4
  declare type PromiseOrNot<T> = Promise<T> | T;
@@ -11,11 +11,9 @@ export declare type Hook<Exposed, Normalized = Exposed, Result = Normalized exte
11
11
  result: Result;
12
12
  };
13
13
  export declare type LifeCycleHook<T extends unknown[] = []> = Hook<(app: App, ...args: T) => PromiseOrNot<void>>;
14
+ export declare type ExtendsHook<T> = Hook<(extendable: T, app: App) => PromiseOrNot<void>>;
14
15
  export declare type ClientFilesHook = Hook<string | string[] | ((app: App) => PromiseOrNot<string | string[]>), (app: App) => Promise<string[]>>;
15
16
  export declare type ReturnObjectHook = Hook<Record<string, any> | ((app: App) => PromiseOrNot<Record<string, any>>), (app: App) => Promise<Record<string, any>>>;
16
- export declare type ExtendsMarkdownHook = Hook<(md: Markdown, app: App) => PromiseOrNot<void>>;
17
- export declare type ExtendsPageOptionsHook = Hook<(options: PageOptions, app: App) => PromiseOrNot<PageOptions>>;
18
- export declare type ExtendsPageDataHook = Hook<(page: Omit<Page, 'data'>, app: App) => PromiseOrNot<Record<string, any>>>;
19
17
  /**
20
18
  * List of hooks
21
19
  */
@@ -24,9 +22,10 @@ export interface Hooks {
24
22
  onPrepared: LifeCycleHook;
25
23
  onWatched: LifeCycleHook<[watchers: Closable[], restart: () => Promise<void>]>;
26
24
  onGenerated: LifeCycleHook;
27
- extendsMarkdown: ExtendsMarkdownHook;
28
- extendsPageOptions: ExtendsPageOptionsHook;
29
- extendsPageData: ExtendsPageDataHook;
25
+ extendsMarkdownOptions: ExtendsHook<MarkdownOptions>;
26
+ extendsMarkdown: ExtendsHook<Markdown>;
27
+ extendsPageOptions: ExtendsHook<PageOptions>;
28
+ extendsPage: ExtendsHook<Page>;
30
29
  clientAppEnhanceFiles: ClientFilesHook;
31
30
  clientAppRootComponentFiles: ClientFilesHook;
32
31
  clientAppSetupFiles: ClientFilesHook;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/core",
3
- "version": "2.0.0-beta.26",
3
+ "version": "2.0.0-beta.32",
4
4
  "description": "Core package of VuePress",
5
5
  "keywords": [
6
6
  "vuepress",
@@ -26,15 +26,15 @@
26
26
  "clean": "rimraf lib *.tsbuildinfo"
27
27
  },
28
28
  "dependencies": {
29
- "@vuepress/client": "2.0.0-beta.26",
30
- "@vuepress/markdown": "2.0.0-beta.25",
31
- "@vuepress/shared": "2.0.0-beta.25",
32
- "@vuepress/utils": "2.0.0-beta.25",
29
+ "@vuepress/client": "2.0.0-beta.32",
30
+ "@vuepress/markdown": "2.0.0-beta.32",
31
+ "@vuepress/shared": "2.0.0-beta.32",
32
+ "@vuepress/utils": "2.0.0-beta.32",
33
33
  "gray-matter": "^4.0.3",
34
34
  "toml": "^3.0.0"
35
35
  },
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "6cbf3e07b2871383cebad5180fcbb02d69c79566"
39
+ "gitHead": "8ffa71313607fe78f3956e3ccb886fcae0ddf5e9"
40
40
  }
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAppDir = 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
- * Create directory utils for vuepress app
14
- */
15
- const createAppDir = (options) => {
16
- const cache = exports.createAppDirFunction(options.cache);
17
- const temp = exports.createAppDirFunction(options.temp);
18
- const source = exports.createAppDirFunction(options.source);
19
- const dest = exports.createAppDirFunction(options.dest);
20
- const publicDir = exports.createAppDirFunction(options.public);
21
- // @vuepress/client
22
- const client = 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.createAppDir = createAppDir;
@@ -1,5 +0,0 @@
1
- import type { AppEnv, AppOptions } from '../types';
2
- /**
3
- * Create environment flags for vuepress app
4
- */
5
- export declare const createAppEnv: (options: AppOptions, isBuild: boolean) => AppEnv;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAppEnv = void 0;
4
- /**
5
- * Create environment flags for vuepress app
6
- */
7
- const createAppEnv = (options, isBuild) => ({
8
- isBuild,
9
- isDev: !isBuild,
10
- isDebug: options.debug,
11
- });
12
- exports.createAppEnv = createAppEnv;
@@ -1,5 +0,0 @@
1
- import type { AppConfig, AppOptions } from '../types';
2
- /**
3
- * Create app options with default values
4
- */
5
- export declare const createAppOptions: ({ base, lang, title, description, head, locales, theme, themeConfig, bundler, bundlerConfig, source, dest, temp, cache, public: publicDir, markdown, host, port, debug, open, pagePatterns, templateDev, templateSSR, shouldPreload, shouldPrefetch, plugins, }: AppConfig) => AppOptions;
@@ -1,5 +0,0 @@
1
- import type { App, Page } from '../types';
2
- /**
3
- * Create pages for vuepress app
4
- */
5
- export declare const createAppPages: (app: App) => Promise<Page[]>;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAppPages = void 0;
4
- const utils_1 = require("@vuepress/utils");
5
- const page_1 = require("../page");
6
- const log = utils_1.debug('vuepress:core/app');
7
- /**
8
- * Create pages for vuepress app
9
- */
10
- const createAppPages = async (app) => {
11
- log('createAppPages start');
12
- // resolve page absolute file paths according to the page patterns
13
- const pageFilePaths = await 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) => 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 page_1.createPage(app, {
22
- path: '/404.html',
23
- frontmatter: {
24
- layout: '404',
25
- },
26
- }));
27
- }
28
- log('createAppPages finish');
29
- return pages;
30
- };
31
- exports.createAppPages = createAppPages;
@@ -1,7 +0,0 @@
1
- import type { AppOptions, SiteData } from '../types';
2
- /**
3
- * Create site data for vuepress app
4
- *
5
- * Site data will also be used in client
6
- */
7
- export declare const createAppSiteData: (options: AppOptions) => SiteData;
@@ -1,4 +0,0 @@
1
- /**
2
- * Create version of vuepress app
3
- */
4
- export declare const createAppVersion: () => string;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAppVersion = void 0;
4
- /**
5
- * Create version of vuepress app
6
- */
7
- const createAppVersion = () => {
8
- return require('../../package.json').version;
9
- };
10
- exports.createAppVersion = createAppVersion;
@@ -1,5 +0,0 @@
1
- import type { AppDir, AppWriteTemp } from '../types';
2
- /**
3
- * Create write temp file util for vuepress app
4
- */
5
- export declare const createAppWriteTemp: (dir: AppDir) => AppWriteTemp;
@@ -1,5 +0,0 @@
1
- import type { App, Plugin, PluginObject, PluginOptions } from '../types';
2
- /**
3
- * Resolve a plugin according to name / path / module and config
4
- */
5
- export declare const resolvePlugin: <T extends PluginOptions = PluginOptions, U extends PluginObject = PluginObject>(app: App, plugin: string | Plugin<T, U>, config?: Partial<T>) => U;
@@ -1,22 +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
- const resolvePluginModule_1 = require("./resolvePluginModule");
7
- /**
8
- * Resolve a plugin according to name / path / module and config
9
- */
10
- const resolvePlugin = (app, plugin, config = {}) => {
11
- const pluginModule = shared_1.isString(plugin)
12
- ? resolvePluginModule_1.resolvePluginModule(plugin)
13
- : plugin;
14
- if (pluginModule === null) {
15
- throw utils_1.logger.createError(`plugin is not found: ${utils_1.chalk.magenta(plugin)}`);
16
- }
17
- const pluginObject = shared_1.isFunction(pluginModule)
18
- ? pluginModule(config, app)
19
- : pluginModule;
20
- return pluginObject;
21
- };
22
- exports.resolvePlugin = resolvePlugin;
@@ -1,5 +0,0 @@
1
- import type { App, ThemeObject } from '../types';
2
- /**
3
- * Resolve a theme according to the theme name
4
- */
5
- export declare const resolveTheme: (app: App, themeName: string) => ThemeObject;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveTheme = void 0;
4
- const shared_1 = require("@vuepress/shared");
5
- const utils_1 = require("@vuepress/utils");
6
- const resolvePlugin_1 = require("./resolvePlugin");
7
- /**
8
- * Resolve a theme according to the theme name
9
- */
10
- const resolveTheme = (app, themeName) => {
11
- // resolve theme entry according to theme name
12
- const themeEntry = utils_1.requireResolve(utils_1.path.isAbsolute(themeName)
13
- ? themeName
14
- : shared_1.normalizePackageName(themeName, 'vuepress', 'theme'));
15
- if (themeEntry === null) {
16
- throw utils_1.logger.createError(`theme is not found: ${utils_1.chalk.magenta(themeName)}`);
17
- }
18
- // resolve theme from theme entry
19
- const theme = resolvePlugin_1.resolvePlugin(app, themeEntry, app.options.themeConfig);
20
- return theme;
21
- };
22
- exports.resolveTheme = resolveTheme;
@@ -1,8 +0,0 @@
1
- import type { App, Page, PageData } from '../types';
2
- /**
3
- * Resolve page data
4
- */
5
- export declare const resolvePageData: ({ app, page, }: {
6
- app: App;
7
- page: Page;
8
- }) => Promise<PageData>;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageData = void 0;
4
- /**
5
- * Resolve page data
6
- */
7
- const resolvePageData = async ({ app, page, }) => {
8
- const { key, path, title, lang, frontmatter, excerpt, headers } = page;
9
- const data = {
10
- key,
11
- path,
12
- title,
13
- lang,
14
- frontmatter,
15
- excerpt,
16
- headers,
17
- };
18
- // plugin hook: extendsPageData
19
- const extendsPageData = await app.pluginApi.hooks.extendsPageData.process(page, app);
20
- extendsPageData.forEach((item) => Object.assign(data, item));
21
- return data;
22
- };
23
- exports.resolvePageData = resolvePageData;
@@ -1,8 +0,0 @@
1
- import type { App, PageOptions } from '../types';
2
- /**
3
- * Render page content and extract related info
4
- */
5
- export declare const resolvePageOptions: ({ app, optionsRaw, }: {
6
- app: App;
7
- optionsRaw: PageOptions;
8
- }) => Promise<PageOptions>;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvePageOptions = void 0;
4
- /**
5
- * Render page content and extract related info
6
- */
7
- const resolvePageOptions = async ({ app, optionsRaw, }) => {
8
- // avoid mutating the original options object provided by user
9
- const options = { ...optionsRaw };
10
- // plugin hook: extendsPageOptions
11
- const extendsPageOptions = await app.pluginApi.hooks.extendsPageOptions.process(options, app);
12
- extendsPageOptions.forEach((item) => Object.assign(options, item));
13
- return options;
14
- };
15
- exports.resolvePageOptions = resolvePageOptions;