@vuepress/shared 2.0.0-rc.0 → 2.0.0-rc.2
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/LICENSE +1 -1
- package/README.md +12 -0
- package/dist/index.d.ts +11 -3
- package/dist/index.js +24 -14
- package/package.json +5 -6
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2018-present,
|
|
3
|
+
Copyright (c) 2018-present, VuePress Community
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @vuepress/shared
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@vuepress/shared)
|
|
4
|
+
[](https://github.com/vuepress/core/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
## Documentation
|
|
7
|
+
|
|
8
|
+
https://v2.vuepress.vuejs.org
|
|
9
|
+
|
|
10
|
+
## License
|
|
11
|
+
|
|
12
|
+
[MIT](https://github.com/vuepress/core/blob/main/LICENSE)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { MarkdownItHeader } from '@mdit-vue/types';
|
|
2
|
-
export { isArray, isFunction, isString } from '@vue/shared';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Config for `<head>` tags
|
|
@@ -254,7 +253,7 @@ declare const removeLeadingSlash: (str: string) => string;
|
|
|
254
253
|
/**
|
|
255
254
|
* Resolve identifier of a tag, to avoid duplicated tags in `<head>`
|
|
256
255
|
*/
|
|
257
|
-
declare const resolveHeadIdentifier: ([tag, attrs, content
|
|
256
|
+
declare const resolveHeadIdentifier: ([tag, attrs, content]: HeadConfig) => string | null;
|
|
258
257
|
|
|
259
258
|
/**
|
|
260
259
|
* Resolve the matched locale path of route path
|
|
@@ -263,4 +262,13 @@ declare const resolveLocalePath: (locales: LocaleConfig, routePath: string) => s
|
|
|
263
262
|
|
|
264
263
|
declare const resolveRoutePathFromUrl: (url: string, base?: string) => string;
|
|
265
264
|
|
|
266
|
-
|
|
265
|
+
/**
|
|
266
|
+
* Check if a value is a function
|
|
267
|
+
*/
|
|
268
|
+
declare const isFunction: (val: unknown) => val is Function;
|
|
269
|
+
/**
|
|
270
|
+
* Check if a value is a string
|
|
271
|
+
*/
|
|
272
|
+
declare const isString: (val: unknown) => val is string;
|
|
273
|
+
|
|
274
|
+
export { type HeadAttrsConfig, type HeadConfig, type HeadTag, type HeadTagEmpty, type HeadTagNonEmpty, type LocaleConfig, type LocaleData, type PageBase, type PageData, type PageFrontmatter, type PageHeader, type SiteData, type SiteLocaleConfig, type SiteLocaleData, type VuepressSSRContext, dedupeHead, ensureEndingSlash, ensureLeadingSlash, formatDateString, isFunction, isLinkExternal, isLinkHttp, isLinkWithProtocol, isPlainObject, isString, omit, removeEndingSlash, removeLeadingSlash, resolveHeadIdentifier, resolveLocalePath, resolveRoutePathFromUrl };
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
// src/utils/index.ts
|
|
2
|
-
import { isArray, isFunction, isString } from "@vue/shared";
|
|
3
|
-
|
|
4
1
|
// src/utils/resolveHeadIdentifier.ts
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
var TAGS_ALLOWED = ["link", "meta", "script", "style", "noscript", "template"];
|
|
3
|
+
var TAGS_UNIQUE = ["title", "base"];
|
|
4
|
+
var resolveHeadIdentifier = ([tag, attrs, content]) => {
|
|
5
|
+
if (TAGS_UNIQUE.includes(tag)) {
|
|
6
|
+
return tag;
|
|
7
|
+
}
|
|
8
|
+
if (!TAGS_ALLOWED.includes(tag)) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
10
11
|
if (tag === "meta" && attrs.name) {
|
|
11
12
|
return `${tag}.${attrs.name}`;
|
|
12
13
|
}
|
|
13
|
-
if (["title", "base"].includes(tag)) {
|
|
14
|
-
return tag;
|
|
15
|
-
}
|
|
16
14
|
if (tag === "template" && attrs.id) {
|
|
17
15
|
return `${tag}.${attrs.id}`;
|
|
18
16
|
}
|
|
19
|
-
return JSON.stringify([
|
|
17
|
+
return JSON.stringify([
|
|
18
|
+
tag,
|
|
19
|
+
Object.entries(attrs).map(([key, value]) => {
|
|
20
|
+
if (typeof value === "boolean") {
|
|
21
|
+
return value ? [key, ""] : null;
|
|
22
|
+
}
|
|
23
|
+
return [key, value];
|
|
24
|
+
}).filter((item) => item != null).sort(([keyA], [keyB]) => keyA.localeCompare(keyB)),
|
|
25
|
+
content
|
|
26
|
+
]);
|
|
20
27
|
};
|
|
21
28
|
|
|
22
29
|
// src/utils/dedupeHead.ts
|
|
@@ -25,7 +32,7 @@ var dedupeHead = (head) => {
|
|
|
25
32
|
const result = [];
|
|
26
33
|
head.forEach((item) => {
|
|
27
34
|
const identifier = resolveHeadIdentifier(item);
|
|
28
|
-
if (!identifierSet.has(identifier)) {
|
|
35
|
+
if (identifier && !identifierSet.has(identifier)) {
|
|
29
36
|
identifierSet.add(identifier);
|
|
30
37
|
result.push(item);
|
|
31
38
|
}
|
|
@@ -107,12 +114,15 @@ var resolveRoutePathFromUrl = (url, base = "/") => {
|
|
|
107
114
|
const pathname = url.replace(/^(https?:)?\/\/[^/]*/, "");
|
|
108
115
|
return pathname.startsWith(base) ? `/${pathname.slice(base.length)}` : pathname;
|
|
109
116
|
};
|
|
117
|
+
|
|
118
|
+
// src/utils/typeGuards.ts
|
|
119
|
+
var isFunction = (val) => typeof val === "function";
|
|
120
|
+
var isString = (val) => typeof val === "string";
|
|
110
121
|
export {
|
|
111
122
|
dedupeHead,
|
|
112
123
|
ensureEndingSlash,
|
|
113
124
|
ensureLeadingSlash,
|
|
114
125
|
formatDateString,
|
|
115
|
-
isArray,
|
|
116
126
|
isFunction,
|
|
117
127
|
isLinkExternal,
|
|
118
128
|
isLinkHttp,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuepress/shared",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.2",
|
|
4
4
|
"description": "Utils that shared between VuePress node and client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vuepress",
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
],
|
|
10
10
|
"homepage": "https://github.com/vuepress",
|
|
11
11
|
"bugs": {
|
|
12
|
-
"url": "https://github.com/vuepress/
|
|
12
|
+
"url": "https://github.com/vuepress/core/issues"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "git+https://github.com/vuepress/
|
|
16
|
+
"url": "git+https://github.com/vuepress/core.git"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"author": "meteorlxy",
|
|
@@ -29,8 +29,7 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@mdit-vue/types": "^
|
|
33
|
-
"@vue/shared": "^3.3.8"
|
|
32
|
+
"@mdit-vue/types": "^2.0.0"
|
|
34
33
|
},
|
|
35
34
|
"publishConfig": {
|
|
36
35
|
"access": "public"
|
|
@@ -47,7 +46,7 @@
|
|
|
47
46
|
"outDir": "./dist",
|
|
48
47
|
"sourcemap": false,
|
|
49
48
|
"target": "es2022",
|
|
50
|
-
"tsconfig": "
|
|
49
|
+
"tsconfig": "../../tsconfig.dts.json"
|
|
51
50
|
},
|
|
52
51
|
"scripts": {
|
|
53
52
|
"build": "tsup",
|