@vuepress/core 2.0.0-beta.46 → 2.0.0-beta.49
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.
- package/lib/app/prepare/preparePageComponent.js +1 -1
- package/lib/app/prepare/preparePageData.js +2 -1
- package/lib/app/prepare/preparePagesRoutes.js +4 -31
- package/lib/app/prepare/prepareSiteData.js +1 -1
- package/lib/app/resolveAppOptions.d.ts +1 -1
- package/lib/app/resolveAppOptions.js +2 -1
- package/lib/page/createPage.js +5 -21
- package/lib/page/index.d.ts +0 -3
- package/lib/page/index.js +0 -3
- package/lib/page/renderPageContent.d.ts +6 -4
- package/lib/page/renderPageContent.js +7 -5
- package/lib/page/resolvePagePermalink.d.ts +3 -2
- package/lib/page/resolvePagePermalink.js +17 -7
- package/lib/types/app/options.d.ts +1 -0
- package/lib/types/page.d.ts +4 -4
- package/package.json +6 -8
- package/lib/page/renderPageExcerpt.d.ts +0 -11
- package/lib/page/renderPageExcerpt.js +0 -17
- package/lib/page/resolvePageContent.d.ts +0 -11
- package/lib/page/resolvePageContent.js +0 -30
- package/lib/page/resolvePageFrontmatter.d.ts +0 -8
- package/lib/page/resolvePageFrontmatter.js +0 -12
|
@@ -10,7 +10,7 @@ const preparePageComponent = async (app, page) => {
|
|
|
10
10
|
// #688: wrap the content with a <div> to avoid some potential issues of fragment component
|
|
11
11
|
`<template><div>${page.contentRendered}</div></template>\n`,
|
|
12
12
|
// hoist `<script>`, `<style>` and other custom blocks
|
|
13
|
-
...page.
|
|
13
|
+
...page.sfcBlocks,
|
|
14
14
|
].join('\n'));
|
|
15
15
|
};
|
|
16
16
|
exports.preparePageComponent = preparePageComponent;
|
|
@@ -20,7 +20,8 @@ if (import.meta.hot) {
|
|
|
20
20
|
*/
|
|
21
21
|
const preparePageData = async (app, page) => {
|
|
22
22
|
// page data file content
|
|
23
|
-
let content = `export const data = ${JSON.stringify(page.data
|
|
23
|
+
let content = `export const data = JSON.parse(${JSON.stringify(JSON.stringify(page.data))})
|
|
24
|
+
`;
|
|
24
25
|
// inject HMR code
|
|
25
26
|
if (app.env.isDev) {
|
|
26
27
|
content += HMR_CODE;
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.preparePagesRoutes = void 0;
|
|
4
4
|
const shared_1 = require("@vuepress/shared");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Resolve page route item
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
8
|
+
const resolvePageRouteItem = ({ key, path, pathInferred, filePathRelative, routeMeta, }) => {
|
|
9
9
|
// paths that should redirect to this page, use set to dedupe
|
|
10
10
|
const redirectsSet = new Set();
|
|
11
11
|
// redirect from decoded path
|
|
@@ -37,38 +37,11 @@ const transformPageToRouteItem = ({ key, path, pathInferred, filePathRelative, r
|
|
|
37
37
|
* Generate routes temp file
|
|
38
38
|
*/
|
|
39
39
|
const preparePagesRoutes = async (app) => {
|
|
40
|
-
const routeItems = app.pages.map(
|
|
40
|
+
const routeItems = app.pages.map(resolvePageRouteItem);
|
|
41
41
|
const content = `\
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const routeItems = [\
|
|
42
|
+
export const pagesRoutes = [\
|
|
45
43
|
${routeItems.map((routeItem) => `\n ${JSON.stringify(routeItem)},`).join('')}
|
|
46
44
|
]
|
|
47
|
-
|
|
48
|
-
export const pagesRoutes = routeItems.reduce(
|
|
49
|
-
(result, [name, path, meta, redirects]) => {
|
|
50
|
-
result.push(
|
|
51
|
-
{
|
|
52
|
-
name,
|
|
53
|
-
path,
|
|
54
|
-
component: Vuepress,
|
|
55
|
-
meta,
|
|
56
|
-
},
|
|
57
|
-
...redirects.map((item) => ({
|
|
58
|
-
path: item,
|
|
59
|
-
redirect: path,
|
|
60
|
-
}))
|
|
61
|
-
)
|
|
62
|
-
return result
|
|
63
|
-
},
|
|
64
|
-
[
|
|
65
|
-
{
|
|
66
|
-
name: '404',
|
|
67
|
-
path: '/:catchAll(.*)',
|
|
68
|
-
component: Vuepress,
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
)
|
|
72
45
|
`;
|
|
73
46
|
await app.writeTemp('internal/pagesRoutes.js', content);
|
|
74
47
|
};
|
|
@@ -20,7 +20,7 @@ if (import.meta.hot) {
|
|
|
20
20
|
*/
|
|
21
21
|
const prepareSiteData = async (app) => {
|
|
22
22
|
let content = `\
|
|
23
|
-
export const siteData = ${JSON.stringify(app.siteData
|
|
23
|
+
export const siteData = JSON.parse(${JSON.stringify(JSON.stringify(app.siteData))})
|
|
24
24
|
`;
|
|
25
25
|
// inject HMR code
|
|
26
26
|
if (app.env.isDev) {
|
|
@@ -2,4 +2,4 @@ import type { AppConfig, AppOptions } from '../types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Create app options with default values
|
|
4
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, plugins, theme, }: AppConfig) => AppOptions;
|
|
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;
|
|
@@ -15,7 +15,7 @@ host = '0.0.0.0', port = 8080, open = false, templateDev = utils_1.path.normaliz
|
|
|
15
15
|
// build config
|
|
16
16
|
shouldPreload = true, shouldPrefetch = true, templateBuild = utils_1.path.normalize(require.resolve('@vuepress/client/templates/build.html')),
|
|
17
17
|
// common config
|
|
18
|
-
bundler, debug = false, markdown = {}, pagePatterns = ['**/*.md', '!.vuepress', '!node_modules'], plugins = [], theme, }) => ({
|
|
18
|
+
bundler, debug = false, markdown = {}, pagePatterns = ['**/*.md', '!.vuepress', '!node_modules'], permalinkPattern = null, plugins = [], theme, }) => ({
|
|
19
19
|
base,
|
|
20
20
|
lang,
|
|
21
21
|
title,
|
|
@@ -38,6 +38,7 @@ bundler, debug = false, markdown = {}, pagePatterns = ['**/*.md', '!.vuepress',
|
|
|
38
38
|
debug,
|
|
39
39
|
markdown,
|
|
40
40
|
pagePatterns,
|
|
41
|
+
permalinkPattern,
|
|
41
42
|
plugins,
|
|
42
43
|
theme,
|
|
43
44
|
});
|
package/lib/page/createPage.js
CHANGED
|
@@ -3,14 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createPage = void 0;
|
|
4
4
|
const inferPagePath_1 = require("./inferPagePath");
|
|
5
5
|
const renderPageContent_1 = require("./renderPageContent");
|
|
6
|
-
const renderPageExcerpt_1 = require("./renderPageExcerpt");
|
|
7
6
|
const resolvePageComponentInfo_1 = require("./resolvePageComponentInfo");
|
|
8
|
-
const resolvePageContent_1 = require("./resolvePageContent");
|
|
9
7
|
const resolvePageDataInfo_1 = require("./resolvePageDataInfo");
|
|
10
8
|
const resolvePageDate_1 = require("./resolvePageDate");
|
|
11
9
|
const resolvePageFileContent_1 = require("./resolvePageFileContent");
|
|
12
10
|
const resolvePageFilePath_1 = require("./resolvePageFilePath");
|
|
13
|
-
const resolvePageFrontmatter_1 = require("./resolvePageFrontmatter");
|
|
14
11
|
const resolvePageHtmlInfo_1 = require("./resolvePageHtmlInfo");
|
|
15
12
|
const resolvePageKey_1 = require("./resolvePageKey");
|
|
16
13
|
const resolvePageLang_1 = require("./resolvePageLang");
|
|
@@ -27,28 +24,14 @@ const createPage = async (app, options) => {
|
|
|
27
24
|
options,
|
|
28
25
|
});
|
|
29
26
|
// read the raw file content according to the absolute file path
|
|
30
|
-
const
|
|
31
|
-
// resolve content & frontmatter & raw excerpt from raw content
|
|
32
|
-
const { content, frontmatterRaw, excerptRaw } = (0, resolvePageContent_1.resolvePageContent)({
|
|
33
|
-
contentRaw,
|
|
34
|
-
});
|
|
35
|
-
// resolve frontmatter from raw frontmatter and page options
|
|
36
|
-
const frontmatter = (0, resolvePageFrontmatter_1.resolvePageFrontmatter)({ frontmatterRaw, options });
|
|
37
|
-
// render excerpt
|
|
38
|
-
const excerpt = (0, renderPageExcerpt_1.renderPageExcerpt)({
|
|
39
|
-
app,
|
|
40
|
-
excerptRaw,
|
|
41
|
-
filePath,
|
|
42
|
-
filePathRelative,
|
|
43
|
-
frontmatter,
|
|
44
|
-
});
|
|
27
|
+
const content = await (0, resolvePageFileContent_1.resolvePageFileContent)({ filePath, options });
|
|
45
28
|
// render page content and extract information
|
|
46
|
-
const { contentRendered, deps,
|
|
29
|
+
const { contentRendered, deps, excerpt, frontmatter, headers, links, sfcBlocks, title, } = await (0, renderPageContent_1.renderPageContent)({
|
|
47
30
|
app,
|
|
48
31
|
content,
|
|
49
32
|
filePath,
|
|
50
33
|
filePathRelative,
|
|
51
|
-
|
|
34
|
+
options,
|
|
52
35
|
});
|
|
53
36
|
// resolve route meta from frontmatter
|
|
54
37
|
const routeMeta = (0, resolvePageRouteMeta_1.resolvePageRouteMeta)({ frontmatter });
|
|
@@ -62,6 +45,7 @@ const createPage = async (app, options) => {
|
|
|
62
45
|
const lang = (0, resolvePageLang_1.resolvePageLang)({ app, frontmatter, pathLocale });
|
|
63
46
|
// resolve page permalink
|
|
64
47
|
const permalink = (0, resolvePagePermalink_1.resolvePagePermalink)({
|
|
48
|
+
app,
|
|
65
49
|
frontmatter,
|
|
66
50
|
slug,
|
|
67
51
|
date,
|
|
@@ -108,12 +92,12 @@ const createPage = async (app, options) => {
|
|
|
108
92
|
contentRendered,
|
|
109
93
|
date,
|
|
110
94
|
deps,
|
|
111
|
-
hoistedTags,
|
|
112
95
|
links,
|
|
113
96
|
pathInferred,
|
|
114
97
|
pathLocale,
|
|
115
98
|
permalink,
|
|
116
99
|
routeMeta,
|
|
100
|
+
sfcBlocks,
|
|
117
101
|
slug,
|
|
118
102
|
// file info
|
|
119
103
|
filePath,
|
package/lib/page/index.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
export * from './createPage';
|
|
2
2
|
export * from './inferPagePath';
|
|
3
3
|
export * from './renderPageContent';
|
|
4
|
-
export * from './renderPageExcerpt';
|
|
5
4
|
export * from './resolvePageComponentInfo';
|
|
6
|
-
export * from './resolvePageContent';
|
|
7
5
|
export * from './resolvePageDataInfo';
|
|
8
6
|
export * from './resolvePageDate';
|
|
9
7
|
export * from './resolvePageFileContent';
|
|
10
8
|
export * from './resolvePageFilePath';
|
|
11
|
-
export * from './resolvePageFrontmatter';
|
|
12
9
|
export * from './resolvePageHtmlInfo';
|
|
13
10
|
export * from './resolvePageKey';
|
|
14
11
|
export * from './resolvePageLang';
|
package/lib/page/index.js
CHANGED
|
@@ -17,14 +17,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./createPage"), exports);
|
|
18
18
|
__exportStar(require("./inferPagePath"), exports);
|
|
19
19
|
__exportStar(require("./renderPageContent"), exports);
|
|
20
|
-
__exportStar(require("./renderPageExcerpt"), exports);
|
|
21
20
|
__exportStar(require("./resolvePageComponentInfo"), exports);
|
|
22
|
-
__exportStar(require("./resolvePageContent"), exports);
|
|
23
21
|
__exportStar(require("./resolvePageDataInfo"), exports);
|
|
24
22
|
__exportStar(require("./resolvePageDate"), exports);
|
|
25
23
|
__exportStar(require("./resolvePageFileContent"), exports);
|
|
26
24
|
__exportStar(require("./resolvePageFilePath"), exports);
|
|
27
|
-
__exportStar(require("./resolvePageFrontmatter"), exports);
|
|
28
25
|
__exportStar(require("./resolvePageHtmlInfo"), exports);
|
|
29
26
|
__exportStar(require("./resolvePageKey"), exports);
|
|
30
27
|
__exportStar(require("./resolvePageLang"), exports);
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import type { MarkdownHeader, MarkdownLink } from '@vuepress/markdown';
|
|
2
|
-
import type { App, PageFrontmatter } from '../types';
|
|
2
|
+
import type { App, PageFrontmatter, PageOptions } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Render page content and extract related info
|
|
5
5
|
*/
|
|
6
|
-
export declare const renderPageContent: ({ app, content,
|
|
6
|
+
export declare const renderPageContent: ({ app, content, filePath, filePathRelative, options, }: {
|
|
7
7
|
app: App;
|
|
8
8
|
content: string;
|
|
9
|
-
frontmatter: PageFrontmatter;
|
|
10
9
|
filePath: string | null;
|
|
11
10
|
filePathRelative: string | null;
|
|
11
|
+
options: PageOptions;
|
|
12
12
|
}) => Promise<{
|
|
13
13
|
contentRendered: string;
|
|
14
14
|
deps: string[];
|
|
15
|
+
excerpt: string;
|
|
16
|
+
frontmatter: PageFrontmatter;
|
|
15
17
|
headers: MarkdownHeader[];
|
|
16
|
-
hoistedTags: string[];
|
|
17
18
|
links: MarkdownLink[];
|
|
19
|
+
sfcBlocks: string[];
|
|
18
20
|
title: string;
|
|
19
21
|
}>;
|
|
@@ -4,23 +4,25 @@ exports.renderPageContent = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Render page content and extract related info
|
|
6
6
|
*/
|
|
7
|
-
const renderPageContent = async ({ app, content,
|
|
7
|
+
const renderPageContent = async ({ app, content, filePath, filePathRelative, options, }) => {
|
|
8
8
|
const markdownEnv = {
|
|
9
9
|
base: app.options.base,
|
|
10
10
|
filePath,
|
|
11
11
|
filePathRelative,
|
|
12
|
-
frontmatter,
|
|
12
|
+
frontmatter: { ...options.frontmatter },
|
|
13
13
|
};
|
|
14
14
|
const contentRendered = app.markdown.render(content, markdownEnv);
|
|
15
15
|
/* istanbul ignore next */
|
|
16
|
-
const { headers = [],
|
|
16
|
+
const { excerpt = '', frontmatter = {}, headers = [], importedFiles = [], links = [], sfcBlocks = [], title = '', } = markdownEnv;
|
|
17
17
|
return {
|
|
18
18
|
contentRendered,
|
|
19
19
|
deps: importedFiles,
|
|
20
|
+
excerpt,
|
|
21
|
+
frontmatter,
|
|
20
22
|
headers,
|
|
21
|
-
hoistedTags,
|
|
22
23
|
links,
|
|
23
|
-
|
|
24
|
+
sfcBlocks,
|
|
25
|
+
title: frontmatter.title ?? title,
|
|
24
26
|
};
|
|
25
27
|
};
|
|
26
28
|
exports.renderPageContent = renderPageContent;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { PageFrontmatter } from '../types';
|
|
1
|
+
import type { App, PageFrontmatter } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Resolve page permalink from frontmatter / options / pattern
|
|
4
4
|
*/
|
|
5
|
-
export declare const resolvePagePermalink: ({ frontmatter, slug, date, pathInferred, pathLocale, }: {
|
|
5
|
+
export declare const resolvePagePermalink: ({ app, frontmatter, slug, date, pathInferred, pathLocale, }: {
|
|
6
|
+
app: App;
|
|
6
7
|
frontmatter: PageFrontmatter;
|
|
7
8
|
slug: string;
|
|
8
9
|
date: string;
|
|
@@ -6,21 +6,19 @@ const utils_1 = require("@vuepress/utils");
|
|
|
6
6
|
/**
|
|
7
7
|
* Resolve page permalink from frontmatter / options / pattern
|
|
8
8
|
*/
|
|
9
|
-
const resolvePagePermalink = ({ frontmatter, slug, date, pathInferred, pathLocale, }) => {
|
|
9
|
+
const resolvePagePermalink = ({ app, frontmatter, slug, date, pathInferred, pathLocale, }) => {
|
|
10
10
|
// use permalink in frontmatter directly
|
|
11
11
|
if ((0, shared_1.isString)(frontmatter.permalink)) {
|
|
12
12
|
return frontmatter.permalink;
|
|
13
13
|
}
|
|
14
|
-
// get permalink pattern
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
: null;
|
|
18
|
-
if (!pattern) {
|
|
14
|
+
// get permalink pattern
|
|
15
|
+
const permalinkPattern = getPermalinkPattern({ app, frontmatter });
|
|
16
|
+
if (permalinkPattern === null) {
|
|
19
17
|
return null;
|
|
20
18
|
}
|
|
21
19
|
// resolve permalink according to the pattern
|
|
22
20
|
const [year, month, day] = date.split('-');
|
|
23
|
-
const link = utils_1.path.join(pathLocale,
|
|
21
|
+
const link = utils_1.path.join(pathLocale, permalinkPattern
|
|
24
22
|
.replace(/:year/, year)
|
|
25
23
|
.replace(/:month/, month)
|
|
26
24
|
.replace(/:day/, day)
|
|
@@ -29,3 +27,15 @@ const resolvePagePermalink = ({ frontmatter, slug, date, pathInferred, pathLocal
|
|
|
29
27
|
return (0, shared_1.ensureLeadingSlash)(link);
|
|
30
28
|
};
|
|
31
29
|
exports.resolvePagePermalink = resolvePagePermalink;
|
|
30
|
+
/**
|
|
31
|
+
* Get permalink pattern from frontmatter or app options
|
|
32
|
+
*/
|
|
33
|
+
const getPermalinkPattern = ({ app, frontmatter, }) => {
|
|
34
|
+
if (frontmatter.permalinkPattern === null) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
if ((0, shared_1.isString)(frontmatter.permalinkPattern)) {
|
|
38
|
+
return frontmatter.permalinkPattern;
|
|
39
|
+
}
|
|
40
|
+
return app.options.permalinkPattern;
|
|
41
|
+
};
|
package/lib/types/page.d.ts
CHANGED
|
@@ -26,10 +26,6 @@ export declare type Page<ExtraPageData extends Record<any, any> = Record<never,
|
|
|
26
26
|
* Dependencies of the page
|
|
27
27
|
*/
|
|
28
28
|
deps: string[];
|
|
29
|
-
/**
|
|
30
|
-
* Hoisted tags of the page
|
|
31
|
-
*/
|
|
32
|
-
hoistedTags: string[];
|
|
33
29
|
/**
|
|
34
30
|
* Links of the page
|
|
35
31
|
*/
|
|
@@ -62,6 +58,10 @@ export declare type Page<ExtraPageData extends Record<any, any> = Record<never,
|
|
|
62
58
|
* @see https://router.vuejs.org/api/#meta
|
|
63
59
|
*/
|
|
64
60
|
routeMeta: Record<string, unknown>;
|
|
61
|
+
/**
|
|
62
|
+
* Extracted sfc blocks of the page
|
|
63
|
+
*/
|
|
64
|
+
sfcBlocks: string[];
|
|
65
65
|
/**
|
|
66
66
|
* Slug of the page
|
|
67
67
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.49",
|
|
4
4
|
"description": "Core package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -22,13 +22,11 @@
|
|
|
22
22
|
"lib"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@vuepress/client": "2.0.0-beta.
|
|
26
|
-
"@vuepress/markdown": "2.0.0-beta.
|
|
27
|
-
"@vuepress/shared": "2.0.0-beta.
|
|
28
|
-
"@vuepress/utils": "2.0.0-beta.
|
|
29
|
-
"
|
|
30
|
-
"toml": "^3.0.0",
|
|
31
|
-
"vue": "^3.2.35"
|
|
25
|
+
"@vuepress/client": "2.0.0-beta.49",
|
|
26
|
+
"@vuepress/markdown": "2.0.0-beta.49",
|
|
27
|
+
"@vuepress/shared": "2.0.0-beta.49",
|
|
28
|
+
"@vuepress/utils": "2.0.0-beta.49",
|
|
29
|
+
"vue": "^3.2.37"
|
|
32
30
|
},
|
|
33
31
|
"publishConfig": {
|
|
34
32
|
"access": "public"
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { App, PageFrontmatter } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Render page excerpt from raw excerpt
|
|
4
|
-
*/
|
|
5
|
-
export declare const renderPageExcerpt: ({ app, excerptRaw, frontmatter, filePath, filePathRelative, }: {
|
|
6
|
-
app: App;
|
|
7
|
-
excerptRaw: string;
|
|
8
|
-
frontmatter: PageFrontmatter;
|
|
9
|
-
filePath: string | null;
|
|
10
|
-
filePathRelative: string | null;
|
|
11
|
-
}) => string;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renderPageExcerpt = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Render page excerpt from raw excerpt
|
|
6
|
-
*/
|
|
7
|
-
const renderPageExcerpt = ({ app, excerptRaw, frontmatter, filePath, filePathRelative, }) => {
|
|
8
|
-
const markdownEnv = {
|
|
9
|
-
base: app.options.base,
|
|
10
|
-
filePath,
|
|
11
|
-
filePathRelative,
|
|
12
|
-
frontmatter,
|
|
13
|
-
};
|
|
14
|
-
const renderedExcerpt = app.markdown.render(excerptRaw, markdownEnv);
|
|
15
|
-
return renderedExcerpt;
|
|
16
|
-
};
|
|
17
|
-
exports.renderPageExcerpt = renderPageExcerpt;
|
|
@@ -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,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;
|