@vuepress/client 2.0.0-beta.4 → 2.0.0-beta.42
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
package/lib/app.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { computed, h } from 'vue';
|
|
2
|
-
import { createRouter, RouterView, START_LOCATION } from 'vue-router';
|
|
3
|
-
import { removeEndingSlash } from '@vuepress/shared';
|
|
4
|
-
import { clientAppEnhances } from '@internal/clientAppEnhances';
|
|
5
|
-
import { clientAppRootComponents } from '@internal/clientAppRootComponents';
|
|
6
|
-
import { clientAppSetups } from '@internal/clientAppSetups';
|
|
7
|
-
import { pagesComponent } from '@internal/pagesComponent';
|
|
8
|
-
import { pagesRoutes } from '@internal/pagesRoutes';
|
|
9
|
-
import { siteData, pageData, resolvePageData, pageFrontmatterSymbol, resolvePageFrontmatter, pageHeadSymbol, resolvePageHead, pageHeadTitleSymbol, resolvePageHeadTitle, pageLangSymbol, resolvePageLang, routeLocaleSymbol, resolveRouteLocale, siteLocaleDataSymbol, resolveSiteLocaleData, useUpdateHead, } from './injections';
|
|
10
|
-
import { Content, OutboundLink } from './components';
|
|
11
|
-
import { withBase } from './utils';
|
|
12
|
-
/**
|
|
13
|
-
* Create a vue app
|
|
14
|
-
*
|
|
15
|
-
* Accepting different app creator and history creator, so it
|
|
16
|
-
* can be reused for both client side and server side
|
|
17
|
-
*/
|
|
18
|
-
export const createVueApp = async ({ appCreator, historyCreator, }) => {
|
|
19
|
-
// options to create vue app
|
|
20
|
-
const appOptions = {
|
|
21
|
-
setup() {
|
|
22
|
-
// auto update head
|
|
23
|
-
useUpdateHead();
|
|
24
|
-
// invoke all clientAppSetups
|
|
25
|
-
for (const clientAppSetup of clientAppSetups) {
|
|
26
|
-
clientAppSetup();
|
|
27
|
-
}
|
|
28
|
-
return () => [
|
|
29
|
-
h(RouterView),
|
|
30
|
-
...clientAppRootComponents.map((comp) => h(comp)),
|
|
31
|
-
];
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
// create vue app
|
|
35
|
-
const app = appCreator(appOptions);
|
|
36
|
-
// create vue-router
|
|
37
|
-
const router = createRouter({
|
|
38
|
-
// TODO: it might be an issue of vue-router that have to remove the ending slash
|
|
39
|
-
history: historyCreator(removeEndingSlash(siteData.value.base)),
|
|
40
|
-
routes: pagesRoutes,
|
|
41
|
-
scrollBehavior: (to, from, savedPosition) => {
|
|
42
|
-
if (savedPosition) {
|
|
43
|
-
return savedPosition;
|
|
44
|
-
}
|
|
45
|
-
if (to.hash) {
|
|
46
|
-
return { el: to.hash };
|
|
47
|
-
}
|
|
48
|
-
return { top: 0 };
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
// use vue-router
|
|
52
|
-
app.use(router);
|
|
53
|
-
router.beforeResolve(async (to, from) => {
|
|
54
|
-
if (to.path !== from.path || from === START_LOCATION) {
|
|
55
|
-
pageData.value = await resolvePageData(to.path);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
// create global computed
|
|
59
|
-
const routeLocale = computed(() => resolveRouteLocale(siteData.value.locales, router.currentRoute.value.path));
|
|
60
|
-
const siteLocaleData = computed(() => resolveSiteLocaleData(siteData.value, routeLocale.value));
|
|
61
|
-
const pageFrontmatter = computed(() => resolvePageFrontmatter(pageData.value));
|
|
62
|
-
const pageHeadTitle = computed(() => resolvePageHeadTitle(pageData.value, siteLocaleData.value));
|
|
63
|
-
const pageHead = computed(() => resolvePageHead(pageHeadTitle.value, pageFrontmatter.value, siteLocaleData.value));
|
|
64
|
-
const pageLang = computed(() => resolvePageLang(pageData.value));
|
|
65
|
-
// provide global computed
|
|
66
|
-
app.provide(routeLocaleSymbol, routeLocale);
|
|
67
|
-
app.provide(siteLocaleDataSymbol, siteLocaleData);
|
|
68
|
-
app.provide(pageFrontmatterSymbol, pageFrontmatter);
|
|
69
|
-
app.provide(pageHeadTitleSymbol, pageHeadTitle);
|
|
70
|
-
app.provide(pageHeadSymbol, pageHead);
|
|
71
|
-
app.provide(pageLangSymbol, pageLang);
|
|
72
|
-
// provide global data & helpers
|
|
73
|
-
Object.defineProperties(app.config.globalProperties, {
|
|
74
|
-
$routeLocale: {
|
|
75
|
-
get() {
|
|
76
|
-
return routeLocale.value;
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
$site: {
|
|
80
|
-
get() {
|
|
81
|
-
return siteData.value;
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
$siteLocale: {
|
|
85
|
-
get() {
|
|
86
|
-
return siteLocaleData.value;
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
$page: {
|
|
90
|
-
get() {
|
|
91
|
-
return pageData.value;
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
$frontmatter: {
|
|
95
|
-
get() {
|
|
96
|
-
return pageFrontmatter.value;
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
$lang: {
|
|
100
|
-
get() {
|
|
101
|
-
return pageLang.value;
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
$headTitle: {
|
|
105
|
-
get() {
|
|
106
|
-
return pageHeadTitle.value;
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
$withBase: {
|
|
110
|
-
get() {
|
|
111
|
-
return withBase;
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
// register built-in components
|
|
116
|
-
/* eslint-disable vue/match-component-file-name */
|
|
117
|
-
app.component('ClientOnly', __SSR__ ? () => null : (_, ctx) => { var _a, _b; return (_b = (_a = ctx.slots).default) === null || _b === void 0 ? void 0 : _b.call(_a); });
|
|
118
|
-
app.component('Content', Content);
|
|
119
|
-
app.component('OutboundLink', OutboundLink);
|
|
120
|
-
/* eslint-enable vue/match-component-file-name */
|
|
121
|
-
// register all pages components
|
|
122
|
-
Object.entries(pagesComponent).forEach(([name, component]) => {
|
|
123
|
-
app.component(name, component);
|
|
124
|
-
});
|
|
125
|
-
// invoke all clientAppEnhances
|
|
126
|
-
for (const clientAppEnhance of clientAppEnhances) {
|
|
127
|
-
await clientAppEnhance({ app, router, siteData });
|
|
128
|
-
}
|
|
129
|
-
return {
|
|
130
|
-
app,
|
|
131
|
-
router,
|
|
132
|
-
};
|
|
133
|
-
};
|
package/lib/client.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/client.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createApp } from 'vue';
|
|
2
|
-
import { createWebHistory } from 'vue-router';
|
|
3
|
-
import { createVueApp } from './app';
|
|
4
|
-
/**
|
|
5
|
-
* Client entry point
|
|
6
|
-
*/
|
|
7
|
-
createVueApp({
|
|
8
|
-
appCreator: createApp,
|
|
9
|
-
historyCreator: createWebHistory,
|
|
10
|
-
}).then(({ app, router }) => {
|
|
11
|
-
router.isReady().then(() => {
|
|
12
|
-
app.mount('#app');
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { h } from 'vue';
|
|
2
|
-
import { pagesComponent } from '@internal/pagesComponent';
|
|
3
|
-
import { usePageData } from '../injections';
|
|
4
|
-
/**
|
|
5
|
-
* Markdown rendered content
|
|
6
|
-
*/
|
|
7
|
-
export const Content = (props) => {
|
|
8
|
-
let key;
|
|
9
|
-
// use the page key from props directly
|
|
10
|
-
if (props.pagePath) {
|
|
11
|
-
key = props.pagePath;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
// get current page key from page data
|
|
15
|
-
const page = usePageData();
|
|
16
|
-
key = page.value.path;
|
|
17
|
-
}
|
|
18
|
-
const component = pagesComponent[key];
|
|
19
|
-
// use page component
|
|
20
|
-
if (component) {
|
|
21
|
-
return h(component);
|
|
22
|
-
}
|
|
23
|
-
// fallback
|
|
24
|
-
return h('div', __DEV__
|
|
25
|
-
? 'Page does not exist. This is a fallback content.'
|
|
26
|
-
: '404 Not Found');
|
|
27
|
-
};
|
|
28
|
-
Content.displayName = 'Content';
|
|
29
|
-
Content.props = {
|
|
30
|
-
pagePath: {
|
|
31
|
-
type: String,
|
|
32
|
-
required: false,
|
|
33
|
-
},
|
|
34
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { h } from 'vue';
|
|
2
|
-
import './OutboundLink.css';
|
|
3
|
-
const svg = h('svg', {
|
|
4
|
-
class: 'icon outbound',
|
|
5
|
-
xmlns: 'http://www.w3.org/2000/svg',
|
|
6
|
-
ariaHidden: 'true',
|
|
7
|
-
focusable: 'false',
|
|
8
|
-
x: '0px',
|
|
9
|
-
y: '0px',
|
|
10
|
-
viewBox: '0 0 100 100',
|
|
11
|
-
width: '15',
|
|
12
|
-
height: '15',
|
|
13
|
-
}, [
|
|
14
|
-
h('path', {
|
|
15
|
-
fill: 'currentColor',
|
|
16
|
-
d: 'M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z',
|
|
17
|
-
}),
|
|
18
|
-
h('polygon', {
|
|
19
|
-
fill: 'currentColor',
|
|
20
|
-
points: '45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9',
|
|
21
|
-
}),
|
|
22
|
-
]);
|
|
23
|
-
export const OutboundLink = (_, { slots }) => { var _a; return h('span', [svg, (_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)]); };
|
|
24
|
-
OutboundLink.displayName = 'OutboundLink';
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { h } from 'vue';
|
|
2
|
-
import { isString } from '@vuepress/shared';
|
|
3
|
-
import { layoutComponents } from '@internal/layoutComponents';
|
|
4
|
-
import { usePageData } from '../injections';
|
|
5
|
-
import { Content } from './Content';
|
|
6
|
-
/**
|
|
7
|
-
* Global Layout
|
|
8
|
-
*/
|
|
9
|
-
export const Vuepress = () => {
|
|
10
|
-
// get layout of current page
|
|
11
|
-
let layoutName = '404';
|
|
12
|
-
const page = usePageData();
|
|
13
|
-
if (page.value.path) {
|
|
14
|
-
// if current page exists
|
|
15
|
-
// use layout from frontmatter
|
|
16
|
-
const frontmatterLayout = page.value.frontmatter.layout;
|
|
17
|
-
if (isString(frontmatterLayout)) {
|
|
18
|
-
layoutName = frontmatterLayout;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
// fallback to Layout component
|
|
22
|
-
layoutName = 'Layout';
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const layoutComponent = layoutComponents[layoutName];
|
|
26
|
-
// use layout component
|
|
27
|
-
if (layoutComponent) {
|
|
28
|
-
return h(layoutComponent);
|
|
29
|
-
}
|
|
30
|
-
// fallback to Content
|
|
31
|
-
return h(Content);
|
|
32
|
-
};
|
|
33
|
-
Vuepress.displayName = 'Vuepress';
|
package/lib/components/index.js
DELETED
package/lib/constants.d.ts
DELETED
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './pageData';
|
|
2
|
-
export * from './pageFrontmatter';
|
|
3
|
-
export * from './pageHead';
|
|
4
|
-
export * from './pageHeadTitle';
|
|
5
|
-
export * from './pageLang';
|
|
6
|
-
export * from './pagesData';
|
|
7
|
-
export * from './routeLocale';
|
|
8
|
-
export * from './siteData';
|
|
9
|
-
export * from './siteLocaleData';
|
|
10
|
-
export * from './updateHead';
|
package/lib/injections/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './pageData';
|
|
2
|
-
export * from './pageFrontmatter';
|
|
3
|
-
export * from './pageHead';
|
|
4
|
-
export * from './pageHeadTitle';
|
|
5
|
-
export * from './pageLang';
|
|
6
|
-
export * from './pagesData';
|
|
7
|
-
export * from './routeLocale';
|
|
8
|
-
export * from './siteData';
|
|
9
|
-
export * from './siteLocaleData';
|
|
10
|
-
export * from './updateHead';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Ref } from 'vue';
|
|
2
|
-
import type { PageData } from '@vuepress/shared';
|
|
3
|
-
export type { PageData };
|
|
4
|
-
export declare type PageDataRef<T extends Record<any, any> = Record<never, never>> = Ref<PageData<T>>;
|
|
5
|
-
export declare const pageData: PageDataRef;
|
|
6
|
-
export declare const usePageData: <T extends Record<any, any> = Record<never, never>>() => PageDataRef<T>;
|
|
7
|
-
export declare const resolvePageData: (routePath: string) => Promise<PageData>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ref, readonly } from 'vue';
|
|
2
|
-
import { pagesData } from './pagesData';
|
|
3
|
-
const pageDataEmpty = readonly({
|
|
4
|
-
key: '',
|
|
5
|
-
path: '',
|
|
6
|
-
title: '',
|
|
7
|
-
lang: '',
|
|
8
|
-
frontmatter: {},
|
|
9
|
-
excerpt: '',
|
|
10
|
-
headers: [],
|
|
11
|
-
});
|
|
12
|
-
export const pageData = ref(pageDataEmpty);
|
|
13
|
-
export const usePageData = () => {
|
|
14
|
-
return pageData;
|
|
15
|
-
};
|
|
16
|
-
export const resolvePageData = async (routePath) => {
|
|
17
|
-
const pageDataResolver = pagesData.value[routePath];
|
|
18
|
-
if (!pageDataResolver) {
|
|
19
|
-
return pageDataEmpty;
|
|
20
|
-
}
|
|
21
|
-
const pageData = await pageDataResolver();
|
|
22
|
-
return pageData !== null && pageData !== void 0 ? pageData : pageDataEmpty;
|
|
23
|
-
};
|
|
24
|
-
if (import.meta.webpackHot || import.meta.hot) {
|
|
25
|
-
// reuse vue HMR runtime
|
|
26
|
-
__VUE_HMR_RUNTIME__.updatePageData = (newPageData) => {
|
|
27
|
-
if (newPageData.key === pageData.value.key) {
|
|
28
|
-
pageData.value = newPageData;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
-
import type { PageData, PageFrontmatter } from '@vuepress/shared';
|
|
3
|
-
export type { PageFrontmatter };
|
|
4
|
-
export declare type PageFrontmatterRef<T extends Record<any, any> = Record<string, unknown>> = ComputedRef<PageFrontmatter<T>>;
|
|
5
|
-
export declare const pageFrontmatterSymbol: InjectionKey<PageFrontmatterRef>;
|
|
6
|
-
export declare const usePageFrontmatter: <T extends Record<any, any> = Record<string, unknown>>() => PageFrontmatterRef<T>;
|
|
7
|
-
export declare const resolvePageFrontmatter: (pageData: PageData) => PageFrontmatter;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
export const pageFrontmatterSymbol = Symbol(__DEV__ ? 'pageFrontmatter' : '');
|
|
3
|
-
export const usePageFrontmatter = () => {
|
|
4
|
-
const pageFrontmatter = inject(pageFrontmatterSymbol);
|
|
5
|
-
if (!pageFrontmatter) {
|
|
6
|
-
throw new Error('usePageFrontmatter() is called without provider.');
|
|
7
|
-
}
|
|
8
|
-
return pageFrontmatter;
|
|
9
|
-
};
|
|
10
|
-
export const resolvePageFrontmatter = (pageData) => pageData.frontmatter;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
-
import type { HeadConfig } from '@vuepress/shared';
|
|
3
|
-
import type { PageFrontmatter } from './pageFrontmatter';
|
|
4
|
-
import type { PageHeadTitle } from './pageHeadTitle';
|
|
5
|
-
import type { SiteLocaleData } from './siteLocaleData';
|
|
6
|
-
export declare type PageHead = HeadConfig[];
|
|
7
|
-
export declare type PageHeadRef = ComputedRef<PageHead>;
|
|
8
|
-
export declare const pageHeadSymbol: InjectionKey<PageHeadRef>;
|
|
9
|
-
export declare const usePageHead: () => PageHeadRef;
|
|
10
|
-
/**
|
|
11
|
-
* Merge the head config in frontmatter and site locale
|
|
12
|
-
*
|
|
13
|
-
* Frontmatter should take priority over site locale
|
|
14
|
-
*/
|
|
15
|
-
export declare const resolvePageHead: (headTitle: PageHeadTitle, frontmatter: PageFrontmatter, siteLocale: SiteLocaleData) => HeadConfig[];
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
import { dedupeHead, isArray, isString } from '@vuepress/shared';
|
|
3
|
-
export const pageHeadSymbol = Symbol(__DEV__ ? 'pageHead' : '');
|
|
4
|
-
export const usePageHead = () => {
|
|
5
|
-
const pageHead = inject(pageHeadSymbol);
|
|
6
|
-
if (!pageHead) {
|
|
7
|
-
throw new Error('usePageHead() is called without provider.');
|
|
8
|
-
}
|
|
9
|
-
return pageHead;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Merge the head config in frontmatter and site locale
|
|
13
|
-
*
|
|
14
|
-
* Frontmatter should take priority over site locale
|
|
15
|
-
*/
|
|
16
|
-
export const resolvePageHead = (headTitle, frontmatter, siteLocale) => {
|
|
17
|
-
const description = isString(frontmatter.description)
|
|
18
|
-
? frontmatter.description
|
|
19
|
-
: siteLocale.description;
|
|
20
|
-
const head = [
|
|
21
|
-
...(isArray(frontmatter.head) ? frontmatter.head : []),
|
|
22
|
-
...siteLocale.head,
|
|
23
|
-
['title', {}, headTitle],
|
|
24
|
-
['meta', { name: 'description', content: description }],
|
|
25
|
-
['meta', { charset: 'utf-8' }],
|
|
26
|
-
[
|
|
27
|
-
'meta',
|
|
28
|
-
{ name: 'viewport', content: 'width=device-width,initial-scale=1' },
|
|
29
|
-
],
|
|
30
|
-
['meta', { name: 'generator', content: `VuePress ${__VERSION__}` }],
|
|
31
|
-
];
|
|
32
|
-
return dedupeHead(head);
|
|
33
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
-
import type { PageData } from './pageData';
|
|
3
|
-
import type { SiteLocaleData } from './siteLocaleData';
|
|
4
|
-
export declare type PageHeadTitle = string;
|
|
5
|
-
export declare type PageHeadTitleRef = ComputedRef<PageHeadTitle>;
|
|
6
|
-
export declare const pageHeadTitleSymbol: InjectionKey<PageHeadTitleRef>;
|
|
7
|
-
export declare const usePageHeadTitle: () => PageHeadTitleRef;
|
|
8
|
-
/**
|
|
9
|
-
* Title to displayed in `<head>` tag
|
|
10
|
-
*/
|
|
11
|
-
export declare const resolvePageHeadTitle: (page: PageData, siteLocale: SiteLocaleData) => PageHeadTitle;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
export const pageHeadTitleSymbol = Symbol(__DEV__ ? 'pageHeadTitle' : '');
|
|
3
|
-
export const usePageHeadTitle = () => {
|
|
4
|
-
const pageHeadTitle = inject(pageHeadTitleSymbol);
|
|
5
|
-
if (!pageHeadTitle) {
|
|
6
|
-
throw new Error('usePageHeadTitle() is called without provider.');
|
|
7
|
-
}
|
|
8
|
-
return pageHeadTitle;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Title to displayed in `<head>` tag
|
|
12
|
-
*/
|
|
13
|
-
export const resolvePageHeadTitle = (page, siteLocale) => `${page.title ? `${page.title} | ` : ``}${siteLocale.title}`;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
-
import type { PageData } from '@vuepress/shared';
|
|
3
|
-
export declare type PageLang = string;
|
|
4
|
-
export declare type PageLangRef = ComputedRef<PageLang>;
|
|
5
|
-
export declare const pageLangSymbol: InjectionKey<PageLangRef>;
|
|
6
|
-
export declare const usePageLang: () => PageLangRef;
|
|
7
|
-
/**
|
|
8
|
-
* Resolve language of current page
|
|
9
|
-
*
|
|
10
|
-
* It's mainly used for the `lang` attribute of `<html>` tag,
|
|
11
|
-
* which should not be empty
|
|
12
|
-
*/
|
|
13
|
-
export declare const resolvePageLang: (pageData: PageData) => PageLang;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
export const pageLangSymbol = Symbol(__DEV__ ? 'pageLang' : '');
|
|
3
|
-
export const usePageLang = () => {
|
|
4
|
-
const pageLang = inject(pageLangSymbol);
|
|
5
|
-
if (!pageLang) {
|
|
6
|
-
throw new Error('usePageLang() is called without provider.');
|
|
7
|
-
}
|
|
8
|
-
return pageLang;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Resolve language of current page
|
|
12
|
-
*
|
|
13
|
-
* It's mainly used for the `lang` attribute of `<html>` tag,
|
|
14
|
-
* which should not be empty
|
|
15
|
-
*/
|
|
16
|
-
export const resolvePageLang = (pageData) => pageData.lang || 'en';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Ref } from 'vue';
|
|
2
|
-
import type { PageData } from '@vuepress/shared';
|
|
3
|
-
export declare type PagesData = Record<string, () => Promise<PageData>>;
|
|
4
|
-
export declare type PagesDataRef = Ref<PagesData>;
|
|
5
|
-
export declare const pagesData: PagesDataRef;
|
|
6
|
-
export declare const usePagesData: () => PagesDataRef;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { readonly, ref } from 'vue';
|
|
2
|
-
import { pagesData as pagesDataRaw } from '@internal/pagesData';
|
|
3
|
-
export const pagesData = ref(readonly(pagesDataRaw));
|
|
4
|
-
export const usePagesData = () => {
|
|
5
|
-
return pagesData;
|
|
6
|
-
};
|
|
7
|
-
if (import.meta.webpackHot) {
|
|
8
|
-
import.meta.webpackHot.accept('@internal/pagesData', () => {
|
|
9
|
-
pagesData.value = readonly(pagesDataRaw);
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
if (import.meta.hot) {
|
|
13
|
-
import.meta.hot.accept('@internal/pagesData', () => {
|
|
14
|
-
pagesData.value = readonly(pagesDataRaw);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
-
import type { SiteData } from '@vuepress/shared';
|
|
3
|
-
export declare type RouteLocale = string;
|
|
4
|
-
export declare type RouteLocaleRef = ComputedRef<RouteLocale>;
|
|
5
|
-
export declare const routeLocaleSymbol: InjectionKey<RouteLocaleRef>;
|
|
6
|
-
export declare const useRouteLocale: () => RouteLocaleRef;
|
|
7
|
-
/**
|
|
8
|
-
* Resolve locale path of the route path
|
|
9
|
-
*/
|
|
10
|
-
export declare const resolveRouteLocale: (locales: SiteData['locales'], routePath: string) => RouteLocale;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
import { resolveLocalePath } from '@vuepress/shared';
|
|
3
|
-
export const routeLocaleSymbol = Symbol(__DEV__ ? 'routeLocale' : '');
|
|
4
|
-
export const useRouteLocale = () => {
|
|
5
|
-
const routeLocale = inject(routeLocaleSymbol);
|
|
6
|
-
if (!routeLocale) {
|
|
7
|
-
throw new Error('useRouteLocale() is called without provider.');
|
|
8
|
-
}
|
|
9
|
-
return routeLocale;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Resolve locale path of the route path
|
|
13
|
-
*/
|
|
14
|
-
export const resolveRouteLocale = (locales, routePath) => resolveLocalePath(locales, routePath);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { readonly, ref } from 'vue';
|
|
2
|
-
import { siteData as siteDataRaw } from '@internal/siteData';
|
|
3
|
-
export const siteData = ref(readonly(siteDataRaw));
|
|
4
|
-
export const useSiteData = () => siteData;
|
|
5
|
-
if (import.meta.webpackHot) {
|
|
6
|
-
import.meta.webpackHot.accept('@internal/siteData', () => {
|
|
7
|
-
siteData.value = readonly(siteDataRaw);
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
if (import.meta.hot) {
|
|
11
|
-
import.meta.hot.accept('@internal/siteData', () => {
|
|
12
|
-
siteData.value = readonly(siteDataRaw);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, InjectionKey } from 'vue';
|
|
2
|
-
import type { SiteData } from '@vuepress/shared';
|
|
3
|
-
import type { RouteLocale } from './routeLocale';
|
|
4
|
-
export declare type SiteLocaleData = SiteData;
|
|
5
|
-
export declare type SiteLocaleDataRef = ComputedRef<SiteLocaleData>;
|
|
6
|
-
export declare const siteLocaleDataSymbol: InjectionKey<SiteLocaleDataRef>;
|
|
7
|
-
export declare const useSiteLocaleData: () => SiteLocaleDataRef;
|
|
8
|
-
/**
|
|
9
|
-
* Merge the locales fields to the root fields
|
|
10
|
-
* according to the route path
|
|
11
|
-
*/
|
|
12
|
-
export declare const resolveSiteLocaleData: (site: SiteData, routeLocale: RouteLocale) => SiteLocaleData;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { inject } from 'vue';
|
|
2
|
-
export const siteLocaleDataSymbol = Symbol(__DEV__ ? 'siteLocaleData' : '');
|
|
3
|
-
export const useSiteLocaleData = () => {
|
|
4
|
-
const siteLocaleData = inject(siteLocaleDataSymbol);
|
|
5
|
-
if (!siteLocaleData) {
|
|
6
|
-
throw new Error('useSiteLocaleData() is called without provider.');
|
|
7
|
-
}
|
|
8
|
-
return siteLocaleData;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Merge the locales fields to the root fields
|
|
12
|
-
* according to the route path
|
|
13
|
-
*/
|
|
14
|
-
export const resolveSiteLocaleData = (site, routeLocale) => ({
|
|
15
|
-
...site,
|
|
16
|
-
...site.locales[routeLocale],
|
|
17
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { HeadConfig } from '@vuepress/shared';
|
|
2
|
-
/**
|
|
3
|
-
* Query the matched head tag of head config
|
|
4
|
-
*/
|
|
5
|
-
export declare const queryHeadTag: ([tagName, attrs, content,]: HeadConfig) => HTMLElement | null;
|
|
6
|
-
/**
|
|
7
|
-
* Create head tag from head config
|
|
8
|
-
*/
|
|
9
|
-
export declare const createHeadTag: ([tagName, attrs, content,]: HeadConfig) => HTMLElement | null;
|
|
10
|
-
/**
|
|
11
|
-
* Auto update head
|
|
12
|
-
*
|
|
13
|
-
* This composable function should be used only once in the root app
|
|
14
|
-
*/
|
|
15
|
-
export declare const useUpdateHead: () => void;
|