@vuepress/client 2.0.0-beta.4 → 2.0.0-beta.40
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/dist/app.d.ts +7 -0
- package/dist/app.js +259 -0
- package/dist/chunk-RTLFYRTT.js +250 -0
- package/dist/createVueAppFunction-c8e67ca1.d.ts +9 -0
- package/dist/index.d.ts +220 -0
- package/dist/index.js +70 -0
- package/package.json +53 -16
- package/templates/{index.ssr.html → build.html} +3 -0
- package/templates/{index.dev.html → dev.html} +2 -0
- package/types.d.ts +6 -0
- package/CHANGELOG.md +0 -171
- package/lib/app.d.ts +0 -18
- package/lib/app.js +0 -133
- package/lib/client.d.ts +0 -1
- package/lib/client.js +0 -14
- package/lib/components/Content.d.ts +0 -7
- package/lib/components/Content.js +0 -34
- package/lib/components/OutboundLink.css +0 -7
- package/lib/components/OutboundLink.d.ts +0 -3
- package/lib/components/OutboundLink.js +0 -24
- package/lib/components/Vuepress.d.ts +0 -5
- package/lib/components/Vuepress.js +0 -33
- package/lib/components/index.d.ts +0 -3
- package/lib/components/index.js +0 -3
- package/lib/constants.d.ts +0 -4
- package/lib/index.d.ts +0 -7
- package/lib/index.js +0 -5
- package/lib/injections/index.d.ts +0 -10
- package/lib/injections/index.js +0 -10
- package/lib/injections/pageData.d.ts +0 -7
- package/lib/injections/pageData.js +0 -31
- package/lib/injections/pageFrontmatter.d.ts +0 -7
- package/lib/injections/pageFrontmatter.js +0 -10
- package/lib/injections/pageHead.d.ts +0 -15
- package/lib/injections/pageHead.js +0 -33
- package/lib/injections/pageHeadTitle.d.ts +0 -11
- package/lib/injections/pageHeadTitle.js +0 -13
- package/lib/injections/pageLang.d.ts +0 -13
- package/lib/injections/pageLang.js +0 -16
- package/lib/injections/pagesData.d.ts +0 -6
- package/lib/injections/pagesData.js +0 -16
- package/lib/injections/routeLocale.d.ts +0 -10
- package/lib/injections/routeLocale.js +0 -14
- package/lib/injections/siteData.d.ts +0 -6
- package/lib/injections/siteData.js +0 -14
- package/lib/injections/siteLocaleData.d.ts +0 -12
- package/lib/injections/siteLocaleData.js +0 -17
- package/lib/injections/updateHead.d.ts +0 -15
- package/lib/injections/updateHead.js +0 -100
- package/lib/server.d.ts +0 -8
- package/lib/server.js +0 -10
- package/lib/types/clientAppEnhance.d.ts +0 -8
- package/lib/types/clientAppEnhance.js +0 -1
- package/lib/types/clientAppSetup.d.ts +0 -1
- package/lib/types/clientAppSetup.js +0 -1
- package/lib/types/index.d.ts +0 -7
- package/lib/types/index.js +0 -2
- package/lib/types/internal/clientAppEnhances.d.ts +0 -5
- package/lib/types/internal/clientAppRootComponents.d.ts +0 -5
- package/lib/types/internal/clientAppSetups.d.ts +0 -5
- package/lib/types/internal/layoutComponents.d.ts +0 -5
- package/lib/types/internal/pagesComponent.d.ts +0 -5
- package/lib/types/internal/pagesData.d.ts +0 -5
- package/lib/types/internal/pagesRoutes.d.ts +0 -5
- package/lib/types/internal/siteData.d.ts +0 -5
- package/lib/utils/defineClientAppEnhance.d.ts +0 -2
- package/lib/utils/defineClientAppEnhance.js +0 -1
- package/lib/utils/defineClientAppSetup.d.ts +0 -2
- package/lib/utils/defineClientAppSetup.js +0 -1
- package/lib/utils/index.d.ts +0 -3
- package/lib/utils/index.js +0 -3
- package/lib/utils/withBase.d.ts +0 -4
- package/lib/utils/withBase.js +0 -11
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { onMounted, ref, useSSRContext, watch } from 'vue';
|
|
2
|
-
import { useRoute } from 'vue-router';
|
|
3
|
-
import { isPlainObject, isString } from '@vuepress/shared';
|
|
4
|
-
import { usePageHead } from './pageHead';
|
|
5
|
-
import { usePageLang } from './pageLang';
|
|
6
|
-
/**
|
|
7
|
-
* Query the matched head tag of head config
|
|
8
|
-
*/
|
|
9
|
-
export const queryHeadTag = ([tagName, attrs, content = '',]) => {
|
|
10
|
-
const attrsSelector = Object.entries(attrs).map(([key, value]) => {
|
|
11
|
-
if (isString(value)) {
|
|
12
|
-
return `[${key}="${value}"]`;
|
|
13
|
-
}
|
|
14
|
-
if (value === true) {
|
|
15
|
-
return `[${key}]`;
|
|
16
|
-
}
|
|
17
|
-
return '';
|
|
18
|
-
});
|
|
19
|
-
const selector = `head > ${tagName}${attrsSelector}`;
|
|
20
|
-
const tags = Array.from(document.querySelectorAll(selector));
|
|
21
|
-
const matchedTag = tags.find((item) => item.innerText === content);
|
|
22
|
-
return matchedTag || null;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Create head tag from head config
|
|
26
|
-
*/
|
|
27
|
-
export const createHeadTag = ([tagName, attrs, content,]) => {
|
|
28
|
-
if (!isString(tagName)) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
// create element
|
|
32
|
-
const tag = document.createElement(tagName);
|
|
33
|
-
// set attributes
|
|
34
|
-
if (isPlainObject(attrs)) {
|
|
35
|
-
Object.entries(attrs).forEach(([key, value]) => {
|
|
36
|
-
if (isString(value)) {
|
|
37
|
-
tag.setAttribute(key, value);
|
|
38
|
-
}
|
|
39
|
-
else if (value === true) {
|
|
40
|
-
tag.setAttribute(key, '');
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
// set content
|
|
45
|
-
if (isString(content)) {
|
|
46
|
-
tag.appendChild(document.createTextNode(content));
|
|
47
|
-
}
|
|
48
|
-
return tag;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Auto update head
|
|
52
|
-
*
|
|
53
|
-
* This composable function should be used only once in the root app
|
|
54
|
-
*/
|
|
55
|
-
export const useUpdateHead = () => {
|
|
56
|
-
const route = useRoute();
|
|
57
|
-
const head = usePageHead();
|
|
58
|
-
const lang = usePageLang();
|
|
59
|
-
// ssr-only, extract page meta info to ssrContext
|
|
60
|
-
if (__SSR__) {
|
|
61
|
-
const ssrContext = useSSRContext();
|
|
62
|
-
if (ssrContext) {
|
|
63
|
-
ssrContext.head = head.value;
|
|
64
|
-
ssrContext.lang = lang.value;
|
|
65
|
-
}
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const headTags = ref([]);
|
|
69
|
-
// load current head tags from DOM
|
|
70
|
-
const loadHead = () => {
|
|
71
|
-
head.value.forEach((item) => {
|
|
72
|
-
const tag = queryHeadTag(item);
|
|
73
|
-
if (tag) {
|
|
74
|
-
headTags.value.push(tag);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
// update html lang attribute and head tags to DOM
|
|
79
|
-
const updateHead = () => {
|
|
80
|
-
document.documentElement.lang = lang.value;
|
|
81
|
-
headTags.value.forEach((item) => {
|
|
82
|
-
if (item.parentNode === document.head) {
|
|
83
|
-
document.head.removeChild(item);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
headTags.value.splice(0, headTags.value.length);
|
|
87
|
-
head.value.forEach((item) => {
|
|
88
|
-
const tag = createHeadTag(item);
|
|
89
|
-
if (tag !== null) {
|
|
90
|
-
document.head.appendChild(tag);
|
|
91
|
-
headTags.value.push(tag);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
onMounted(() => {
|
|
96
|
-
loadHead();
|
|
97
|
-
updateHead();
|
|
98
|
-
watch(() => route.path, () => updateHead());
|
|
99
|
-
});
|
|
100
|
-
};
|
package/lib/server.d.ts
DELETED
package/lib/server.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createSSRApp } from 'vue';
|
|
2
|
-
import { createMemoryHistory } from 'vue-router';
|
|
3
|
-
import { createVueApp } from './app';
|
|
4
|
-
/**
|
|
5
|
-
* Server entry point, used for SSR
|
|
6
|
-
*/
|
|
7
|
-
export const createServerApp = async () => createVueApp({
|
|
8
|
-
appCreator: createSSRApp,
|
|
9
|
-
historyCreator: createMemoryHistory,
|
|
10
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare type ClientAppSetup = () => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/types/index.d.ts
DELETED
package/lib/types/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const defineClientAppEnhance = (clientAppEnhance) => clientAppEnhance;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const defineClientAppSetup = (clientAppSetup) => clientAppSetup;
|
package/lib/utils/index.d.ts
DELETED
package/lib/utils/index.js
DELETED
package/lib/utils/withBase.d.ts
DELETED
package/lib/utils/withBase.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { isLinkHttp } from '@vuepress/shared';
|
|
2
|
-
import { useSiteData } from '../injections';
|
|
3
|
-
/**
|
|
4
|
-
* Prefix url with site base
|
|
5
|
-
*/
|
|
6
|
-
export const withBase = (url) => {
|
|
7
|
-
if (isLinkHttp(url))
|
|
8
|
-
return url;
|
|
9
|
-
const base = useSiteData().value.base;
|
|
10
|
-
return `${base}${url}`.replace(/\/+/, '/');
|
|
11
|
-
};
|