@vuepress/shared 2.0.0-rc.15 → 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 +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +9 -9
- package/package.json +1 -1
package/README.md
CHANGED
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 =
|
|
12
|
+
type HeadTag = HeadTagEmpty | HeadTagNonEmpty;
|
|
13
13
|
/**
|
|
14
14
|
* Non-empty tags in `<head>`
|
|
15
15
|
*/
|
|
16
|
-
type HeadTagNonEmpty = '
|
|
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,
|
|
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<
|
|
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<
|
|
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<
|
|
83
|
-
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
|
|
204
|
+
* Infer route path of the given raw path
|
|
205
205
|
*/
|
|
206
|
-
declare const inferRoutePath: (
|
|
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<
|
|
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 = (
|
|
14
|
-
if (!
|
|
15
|
-
let routePath =
|
|
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)
|
|
17
|
+
routePath = `${routePath.substring(0, routePath.length - 3)}.html`;
|
|
18
18
|
} else if (!routePath.endsWith(".html")) {
|
|
19
|
-
routePath = routePath
|
|
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
|
|
113
|
+
var ensureLeadingSlash = (str) => str.startsWith("/") ? str : `/${str}`;
|
|
114
114
|
|
|
115
115
|
// src/utils/ensureEndingSlash.ts
|
|
116
|
-
var ensureEndingSlash = (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
|
|
138
|
+
var removeEndingSlash = (str) => str.endsWith("/") ? str.slice(0, -1) : str;
|
|
139
139
|
|
|
140
140
|
// src/utils/removeLeadingSlash.ts
|
|
141
|
-
var removeLeadingSlash = (str) => 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";
|