@vuepress/shared 2.0.0-rc.14 → 2.0.0-rc.16

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/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  ## Documentation
7
7
 
8
- https://v2.vuepress.vuejs.org
8
+ https://vuepress.vuejs.org
9
9
 
10
10
  ## License
11
11
 
package/dist/index.d.ts CHANGED
@@ -9,11 +9,11 @@ type HeadConfig = [HeadTagEmpty, HeadAttrsConfig] | [HeadTagNonEmpty, HeadAttrsC
9
9
  *
10
10
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head
11
11
  */
12
- type HeadTag = HeadTagNonEmpty | HeadTagEmpty;
12
+ type HeadTag = HeadTagEmpty | HeadTagNonEmpty;
13
13
  /**
14
14
  * Non-empty tags in `<head>`
15
15
  */
16
- type HeadTagNonEmpty = 'title' | 'style' | 'script' | 'noscript' | 'template';
16
+ type HeadTagNonEmpty = 'noscript' | 'script' | 'style' | 'template' | 'title';
17
17
  /**
18
18
  * Empty tags in `<head>`
19
19
  */
@@ -21,7 +21,7 @@ type HeadTagEmpty = 'base' | 'link' | 'meta' | 'script';
21
21
  /**
22
22
  * Attributes to be set for tags in `<head>`
23
23
  */
24
- type HeadAttrsConfig = Record<string, string | boolean>;
24
+ type HeadAttrsConfig = Record<string, boolean | string>;
25
25
 
26
26
  /**
27
27
  * Locales config, a key-value object
@@ -40,7 +40,7 @@ type LocaleData = Record<never, never>;
40
40
  /**
41
41
  * Base type of vuepress page
42
42
  */
43
- interface PageBase<ExtraPageFrontmatter extends Record<any, any> = Record<string, unknown>> {
43
+ interface PageBase<ExtraPageFrontmatter extends Record<string, unknown> = Record<string, unknown>> {
44
44
  /**
45
45
  * Route path of the page
46
46
  *
@@ -72,15 +72,15 @@ interface PageBase<ExtraPageFrontmatter extends Record<any, any> = Record<string
72
72
  /**
73
73
  * Vuepress page data
74
74
  */
75
- type PageData<ExtraPageData extends Record<any, any> = Record<never, never>, ExtraPageFrontmatter extends Record<any, any> = Record<string, unknown>> = PageBase<ExtraPageFrontmatter> & ExtraPageData;
75
+ type PageData<ExtraPageData extends Record<string, unknown> = Record<string, unknown>, ExtraPageFrontmatter extends Record<string, unknown> = Record<string, unknown>> = ExtraPageData & PageBase<ExtraPageFrontmatter>;
76
76
  /**
77
77
  * Vuepress page frontmatter
78
78
  *
79
79
  * Notice that frontmatter is parsed from yaml or other languages,
80
80
  * so we cannot guarantee the type safety
81
81
  */
82
- type PageFrontmatter<T extends Record<any, any> = Record<string, unknown>> = Partial<T> & {
83
- date?: string | Date;
82
+ type PageFrontmatter<T extends Record<string, unknown> = Record<string, unknown>> = Partial<T> & {
83
+ date?: Date | string;
84
84
  description?: string;
85
85
  head?: HeadConfig[];
86
86
  lang?: string;
@@ -201,9 +201,9 @@ declare const isLinkHttp: (link: string) => boolean;
201
201
  declare const isLinkWithProtocol: (link: string) => boolean;
202
202
 
203
203
  /**
204
- * Infer route path according to the given (markdown file) path
204
+ * Infer route path of the given raw path
205
205
  */
206
- declare const inferRoutePath: (path: string) => string;
206
+ declare const inferRoutePath: (rawPath: string) => string;
207
207
 
208
208
  /**
209
209
  * Normalize the given pathname path to the final route path
@@ -277,7 +277,7 @@ declare const isFunction: (val: unknown) => val is Function;
277
277
  /**
278
278
  * Check if a value is plain object, with generic type support
279
279
  */
280
- declare const isPlainObject: <T extends Record<any, any> = Record<any, any>>(val: unknown) => val is T;
280
+ declare const isPlainObject: <T extends Record<string, unknown> = Record<string, unknown>>(val: unknown) => val is T;
281
281
  /**
282
282
  * Check if a value is a string
283
283
  */
package/dist/index.js CHANGED
@@ -10,13 +10,13 @@ link.startsWith("/") && !link.startsWith(base) && !markdownLinkRegexp.test(link)
10
10
  var isLinkHttp = (link) => /^(https?:)?\/\//.test(link);
11
11
 
12
12
  // src/utils/routes/inferRoutePath.ts
13
- var inferRoutePath = (path) => {
14
- if (!path || path.endsWith("/")) return path;
15
- let routePath = path.replace(/(^|\/)README.md$/i, "$1index.html");
13
+ var inferRoutePath = (rawPath) => {
14
+ if (!rawPath || rawPath.endsWith("/")) return rawPath;
15
+ let routePath = rawPath.replace(/(^|\/)README.md$/i, "$1index.html");
16
16
  if (routePath.endsWith(".md")) {
17
- routePath = routePath.substring(0, routePath.length - 3) + ".html";
17
+ routePath = `${routePath.substring(0, routePath.length - 3)}.html`;
18
18
  } else if (!routePath.endsWith(".html")) {
19
- routePath = routePath + ".html";
19
+ routePath = `${routePath}.html`;
20
20
  }
21
21
  if (routePath.endsWith("/index.html")) {
22
22
  routePath = routePath.substring(0, routePath.length - 10);
@@ -110,10 +110,10 @@ var dedupeHead = (head) => {
110
110
  };
111
111
 
112
112
  // src/utils/ensureLeadingSlash.ts
113
- var ensureLeadingSlash = (str) => str[0] === "/" ? str : `/${str}`;
113
+ var ensureLeadingSlash = (str) => str.startsWith("/") ? str : `/${str}`;
114
114
 
115
115
  // src/utils/ensureEndingSlash.ts
116
- var ensureEndingSlash = (str) => str[str.length - 1] === "/" || str.endsWith(".html") ? str : `${str}/`;
116
+ var ensureEndingSlash = (str) => str.endsWith("/") || str.endsWith(".html") ? str : `${str}/`;
117
117
 
118
118
  // src/utils/formatDateString.ts
119
119
  var formatDateString = (str, defaultDateString = "") => {
@@ -135,10 +135,10 @@ var omit = (obj, ...keys) => {
135
135
  };
136
136
 
137
137
  // src/utils/removeEndingSlash.ts
138
- var removeEndingSlash = (str) => str[str.length - 1] === "/" ? str.slice(0, -1) : str;
138
+ var removeEndingSlash = (str) => str.endsWith("/") ? str.slice(0, -1) : str;
139
139
 
140
140
  // src/utils/removeLeadingSlash.ts
141
- var removeLeadingSlash = (str) => str[0] === "/" ? str.slice(1) : str;
141
+ var removeLeadingSlash = (str) => str.startsWith("/") ? str.slice(1) : str;
142
142
 
143
143
  // src/utils/typeGuards.ts
144
144
  var isFunction = (val) => typeof val === "function";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuepress/shared",
3
- "version": "2.0.0-rc.14",
3
+ "version": "2.0.0-rc.16",
4
4
  "description": "Utils that shared between VuePress node and client",
5
5
  "keywords": [
6
6
  "vuepress",