@vuepress/core 2.0.0-beta.44 → 2.0.0-beta.47
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 +2 -1
- package/lib/app/resolveAppOptions.d.ts +1 -1
- package/lib/app/resolveAppOptions.js +2 -1
- package/lib/page/createPage.js +1 -0
- 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/package.json +6 -6
|
@@ -7,7 +7,8 @@ exports.preparePageComponent = void 0;
|
|
|
7
7
|
const preparePageComponent = async (app, page) => {
|
|
8
8
|
await app.writeTemp(page.componentFilePathRelative, [
|
|
9
9
|
// take the rendered markdown content as <template>
|
|
10
|
-
|
|
10
|
+
// #688: wrap the content with a <div> to avoid some potential issues of fragment component
|
|
11
|
+
`<template><div>${page.contentRendered}</div></template>\n`,
|
|
11
12
|
// hoist `<script>`, `<style>` and other custom blocks
|
|
12
13
|
...page.hoistedTags,
|
|
13
14
|
].join('\n'));
|
|
@@ -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
|
@@ -62,6 +62,7 @@ const createPage = async (app, options) => {
|
|
|
62
62
|
const lang = (0, resolvePageLang_1.resolvePageLang)({ app, frontmatter, pathLocale });
|
|
63
63
|
// resolve page permalink
|
|
64
64
|
const permalink = (0, resolvePagePermalink_1.resolvePagePermalink)({
|
|
65
|
+
app,
|
|
65
66
|
frontmatter,
|
|
66
67
|
slug,
|
|
67
68
|
date,
|
|
@@ -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/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.47",
|
|
4
4
|
"description": "Core package of VuePress",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -22,13 +22,13 @@
|
|
|
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.
|
|
25
|
+
"@vuepress/client": "2.0.0-beta.47",
|
|
26
|
+
"@vuepress/markdown": "2.0.0-beta.47",
|
|
27
|
+
"@vuepress/shared": "2.0.0-beta.47",
|
|
28
|
+
"@vuepress/utils": "2.0.0-beta.47",
|
|
29
29
|
"gray-matter": "^4.0.3",
|
|
30
30
|
"toml": "^3.0.0",
|
|
31
|
-
"vue": "^3.2.
|
|
31
|
+
"vue": "^3.2.36"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|