@vuepress/core 2.0.0-beta.46 → 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.
@@ -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
  });
@@ -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 from frontmatter or options
15
- const pattern = (0, shared_1.isString)(frontmatter.permalinkPattern)
16
- ? frontmatter.permalinkPattern
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, pattern
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
+ };
@@ -15,6 +15,7 @@ export interface AppConfigCommon extends Partial<SiteData> {
15
15
  debug?: boolean;
16
16
  markdown?: MarkdownOptions;
17
17
  pagePatterns?: string[];
18
+ permalinkPattern?: string | null;
18
19
  bundler: Bundler;
19
20
  theme: Theme;
20
21
  plugins?: PluginConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/core",
3
- "version": "2.0.0-beta.46",
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.46",
26
- "@vuepress/markdown": "2.0.0-beta.46",
27
- "@vuepress/shared": "2.0.0-beta.46",
28
- "@vuepress/utils": "2.0.0-beta.46",
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.35"
31
+ "vue": "^3.2.36"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"