@vuepress/client 2.0.0-beta.37 → 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 +49 -18
- package/templates/{index.build.html → build.html} +0 -0
- package/templates/{index.dev.html → dev.html} +0 -0
- package/lib/app.d.ts +0 -7
- package/lib/app.js +0 -65
- package/lib/components/ClientOnly.d.ts +0 -3
- package/lib/components/ClientOnly.js +0 -10
- package/lib/components/Content.d.ts +0 -7
- package/lib/components/Content.js +0 -34
- package/lib/components/Vuepress.d.ts +0 -6
- package/lib/components/Vuepress.js +0 -38
- package/lib/components/index.d.ts +0 -3
- package/lib/components/index.js +0 -3
- package/lib/composables/index.d.ts +0 -10
- package/lib/composables/index.js +0 -10
- package/lib/composables/pageData.d.ts +0 -19
- package/lib/composables/pageData.js +0 -31
- package/lib/composables/pageFrontmatter.d.ts +0 -15
- package/lib/composables/pageFrontmatter.js +0 -15
- package/lib/composables/pageHead.d.ts +0 -18
- package/lib/composables/pageHead.js +0 -15
- package/lib/composables/pageHeadTitle.d.ts +0 -17
- package/lib/composables/pageHeadTitle.js +0 -15
- package/lib/composables/pageLang.d.ts +0 -17
- package/lib/composables/pageLang.js +0 -15
- package/lib/composables/pagesData.d.ts +0 -21
- package/lib/composables/pagesData.js +0 -10
- package/lib/composables/routeLocale.d.ts +0 -17
- package/lib/composables/routeLocale.js +0 -15
- package/lib/composables/siteData.d.ts +0 -15
- package/lib/composables/siteData.js +0 -16
- package/lib/composables/siteLocaleData.d.ts +0 -18
- package/lib/composables/siteLocaleData.js +0 -15
- package/lib/composables/updateHead.d.ts +0 -13
- package/lib/composables/updateHead.js +0 -15
- package/lib/helpers/defineClientAppEnhance.d.ts +0 -2
- package/lib/helpers/defineClientAppEnhance.js +0 -1
- package/lib/helpers/defineClientAppSetup.d.ts +0 -2
- package/lib/helpers/defineClientAppSetup.js +0 -1
- package/lib/helpers/index.d.ts +0 -3
- package/lib/helpers/index.js +0 -3
- package/lib/helpers/withBase.d.ts +0 -4
- package/lib/helpers/withBase.js +0 -11
- package/lib/index.d.ts +0 -8
- package/lib/index.js +0 -7
- package/lib/resolvers.d.ts +0 -15
- package/lib/resolvers.js +0 -64
- package/lib/router.d.ts +0 -5
- package/lib/router.js +0 -40
- package/lib/setupDevtools.d.ts +0 -3
- package/lib/setupDevtools.js +0 -22
- package/lib/setupGlobalComponents.d.ts +0 -5
- package/lib/setupGlobalComponents.js +0 -10
- package/lib/setupGlobalComputed.d.ts +0 -34
- package/lib/setupGlobalComputed.js +0 -45
- package/lib/setupUpdateHead.d.ts +0 -13
- package/lib/setupUpdateHead.js +0 -101
- 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 -2
- 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/pagesComponents.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/setupUpdateHead.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { isPlainObject, isString } from '@vuepress/shared';
|
|
2
|
-
import { onMounted, provide, ref, useSSRContext, watch } from 'vue';
|
|
3
|
-
import { useRoute } from 'vue-router';
|
|
4
|
-
import { updateHeadSymbol, usePageHead, usePageLang } from './composables';
|
|
5
|
-
/**
|
|
6
|
-
* Auto update head and provide as global util
|
|
7
|
-
*/
|
|
8
|
-
export const setupUpdateHead = () => {
|
|
9
|
-
const route = useRoute();
|
|
10
|
-
const head = usePageHead();
|
|
11
|
-
const lang = usePageLang();
|
|
12
|
-
// ssr-only, extract page meta info to ssrContext
|
|
13
|
-
if (__VUEPRESS_SSR__) {
|
|
14
|
-
const ssrContext = useSSRContext();
|
|
15
|
-
if (ssrContext) {
|
|
16
|
-
ssrContext.head = head.value;
|
|
17
|
-
ssrContext.lang = lang.value;
|
|
18
|
-
}
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const headTags = ref([]);
|
|
22
|
-
// load current head tags from DOM
|
|
23
|
-
const loadHead = () => {
|
|
24
|
-
head.value.forEach((item) => {
|
|
25
|
-
const tag = queryHeadTag(item);
|
|
26
|
-
if (tag) {
|
|
27
|
-
headTags.value.push(tag);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
// update html lang attribute and head tags to DOM
|
|
32
|
-
const updateHead = () => {
|
|
33
|
-
document.documentElement.lang = lang.value;
|
|
34
|
-
headTags.value.forEach((item) => {
|
|
35
|
-
if (item.parentNode === document.head) {
|
|
36
|
-
document.head.removeChild(item);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
headTags.value.splice(0, headTags.value.length);
|
|
40
|
-
head.value.forEach((item) => {
|
|
41
|
-
const tag = createHeadTag(item);
|
|
42
|
-
if (tag !== null) {
|
|
43
|
-
document.head.appendChild(tag);
|
|
44
|
-
headTags.value.push(tag);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
};
|
|
48
|
-
provide(updateHeadSymbol, updateHead);
|
|
49
|
-
onMounted(() => {
|
|
50
|
-
loadHead();
|
|
51
|
-
updateHead();
|
|
52
|
-
// only update head on route change
|
|
53
|
-
watch(() => route.path, () => updateHead());
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Query the matched head tag of head config
|
|
58
|
-
*/
|
|
59
|
-
export const queryHeadTag = ([tagName, attrs, content = '',]) => {
|
|
60
|
-
const attrsSelector = Object.entries(attrs)
|
|
61
|
-
.map(([key, value]) => {
|
|
62
|
-
if (isString(value)) {
|
|
63
|
-
return `[${key}="${value}"]`;
|
|
64
|
-
}
|
|
65
|
-
if (value === true) {
|
|
66
|
-
return `[${key}]`;
|
|
67
|
-
}
|
|
68
|
-
return '';
|
|
69
|
-
})
|
|
70
|
-
.join('');
|
|
71
|
-
const selector = `head > ${tagName}${attrsSelector}`;
|
|
72
|
-
const tags = Array.from(document.querySelectorAll(selector));
|
|
73
|
-
const matchedTag = tags.find((item) => item.innerText === content);
|
|
74
|
-
return matchedTag || null;
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Create head tag from head config
|
|
78
|
-
*/
|
|
79
|
-
export const createHeadTag = ([tagName, attrs, content,]) => {
|
|
80
|
-
if (!isString(tagName)) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
// create element
|
|
84
|
-
const tag = document.createElement(tagName);
|
|
85
|
-
// set attributes
|
|
86
|
-
if (isPlainObject(attrs)) {
|
|
87
|
-
Object.entries(attrs).forEach(([key, value]) => {
|
|
88
|
-
if (isString(value)) {
|
|
89
|
-
tag.setAttribute(key, value);
|
|
90
|
-
}
|
|
91
|
-
else if (value === true) {
|
|
92
|
-
tag.setAttribute(key, '');
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
// set content
|
|
97
|
-
if (isString(content)) {
|
|
98
|
-
tag.appendChild(document.createTextNode(content));
|
|
99
|
-
}
|
|
100
|
-
return tag;
|
|
101
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { App } from 'vue';
|
|
2
|
-
import type { Router } from 'vue-router';
|
|
3
|
-
import type { SiteDataRef } from '../composables';
|
|
4
|
-
export declare type ClientAppEnhance = (context: {
|
|
5
|
-
app: App;
|
|
6
|
-
router: Router;
|
|
7
|
-
siteData: SiteDataRef;
|
|
8
|
-
}) => void | Promise<void>;
|
|
@@ -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