@vuepress/client 2.0.0-beta.38 → 2.0.0-beta.41

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.
Files changed (77) hide show
  1. package/dist/app.d.ts +7 -0
  2. package/dist/app.js +259 -0
  3. package/dist/chunk-RTLFYRTT.js +250 -0
  4. package/dist/createVueAppFunction-c8e67ca1.d.ts +9 -0
  5. package/dist/index.d.ts +220 -0
  6. package/dist/index.js +70 -0
  7. package/package.json +49 -18
  8. package/templates/{index.build.html → build.html} +0 -0
  9. package/templates/{index.dev.html → dev.html} +0 -0
  10. package/lib/app.d.ts +0 -7
  11. package/lib/app.js +0 -65
  12. package/lib/components/ClientOnly.d.ts +0 -3
  13. package/lib/components/ClientOnly.js +0 -10
  14. package/lib/components/Content.d.ts +0 -7
  15. package/lib/components/Content.js +0 -34
  16. package/lib/components/Vuepress.d.ts +0 -6
  17. package/lib/components/Vuepress.js +0 -38
  18. package/lib/components/index.d.ts +0 -3
  19. package/lib/components/index.js +0 -3
  20. package/lib/composables/index.d.ts +0 -10
  21. package/lib/composables/index.js +0 -10
  22. package/lib/composables/pageData.d.ts +0 -19
  23. package/lib/composables/pageData.js +0 -31
  24. package/lib/composables/pageFrontmatter.d.ts +0 -15
  25. package/lib/composables/pageFrontmatter.js +0 -15
  26. package/lib/composables/pageHead.d.ts +0 -18
  27. package/lib/composables/pageHead.js +0 -15
  28. package/lib/composables/pageHeadTitle.d.ts +0 -17
  29. package/lib/composables/pageHeadTitle.js +0 -15
  30. package/lib/composables/pageLang.d.ts +0 -17
  31. package/lib/composables/pageLang.js +0 -15
  32. package/lib/composables/pagesData.d.ts +0 -21
  33. package/lib/composables/pagesData.js +0 -10
  34. package/lib/composables/routeLocale.d.ts +0 -17
  35. package/lib/composables/routeLocale.js +0 -15
  36. package/lib/composables/siteData.d.ts +0 -15
  37. package/lib/composables/siteData.js +0 -16
  38. package/lib/composables/siteLocaleData.d.ts +0 -18
  39. package/lib/composables/siteLocaleData.js +0 -15
  40. package/lib/composables/updateHead.d.ts +0 -13
  41. package/lib/composables/updateHead.js +0 -15
  42. package/lib/helpers/defineClientAppEnhance.d.ts +0 -2
  43. package/lib/helpers/defineClientAppEnhance.js +0 -1
  44. package/lib/helpers/defineClientAppSetup.d.ts +0 -2
  45. package/lib/helpers/defineClientAppSetup.js +0 -1
  46. package/lib/helpers/index.d.ts +0 -3
  47. package/lib/helpers/index.js +0 -3
  48. package/lib/helpers/withBase.d.ts +0 -4
  49. package/lib/helpers/withBase.js +0 -11
  50. package/lib/index.d.ts +0 -8
  51. package/lib/index.js +0 -7
  52. package/lib/resolvers.d.ts +0 -15
  53. package/lib/resolvers.js +0 -64
  54. package/lib/router.d.ts +0 -5
  55. package/lib/router.js +0 -40
  56. package/lib/setupDevtools.d.ts +0 -3
  57. package/lib/setupDevtools.js +0 -22
  58. package/lib/setupGlobalComponents.d.ts +0 -5
  59. package/lib/setupGlobalComponents.js +0 -10
  60. package/lib/setupGlobalComputed.d.ts +0 -34
  61. package/lib/setupGlobalComputed.js +0 -45
  62. package/lib/setupUpdateHead.d.ts +0 -13
  63. package/lib/setupUpdateHead.js +0 -101
  64. package/lib/types/clientAppEnhance.d.ts +0 -8
  65. package/lib/types/clientAppEnhance.js +0 -1
  66. package/lib/types/clientAppSetup.d.ts +0 -1
  67. package/lib/types/clientAppSetup.js +0 -1
  68. package/lib/types/index.d.ts +0 -2
  69. package/lib/types/index.js +0 -2
  70. package/lib/types/internal/clientAppEnhances.d.ts +0 -5
  71. package/lib/types/internal/clientAppRootComponents.d.ts +0 -5
  72. package/lib/types/internal/clientAppSetups.d.ts +0 -5
  73. package/lib/types/internal/layoutComponents.d.ts +0 -5
  74. package/lib/types/internal/pagesComponents.d.ts +0 -5
  75. package/lib/types/internal/pagesData.d.ts +0 -5
  76. package/lib/types/internal/pagesRoutes.d.ts +0 -5
  77. package/lib/types/internal/siteData.d.ts +0 -5
@@ -1,18 +0,0 @@
1
- import type { HeadConfig } from '@vuepress/shared';
2
- import type { ComputedRef, InjectionKey } from 'vue';
3
- /**
4
- * Page head config, which would be used for generate html tags in `<head>`
5
- */
6
- export declare type PageHead = HeadConfig[];
7
- /**
8
- * Ref wrapper of `PageHead`
9
- */
10
- export declare type PageHeadRef = ComputedRef<PageHead>;
11
- /**
12
- * Injection key for page head
13
- */
14
- export declare const pageHeadSymbol: InjectionKey<PageHeadRef>;
15
- /**
16
- * Returns the ref of the head config of current page
17
- */
18
- export declare const usePageHead: () => PageHeadRef;
@@ -1,15 +0,0 @@
1
- import { inject } from 'vue';
2
- /**
3
- * Injection key for page head
4
- */
5
- export const pageHeadSymbol = Symbol(__VUEPRESS_DEV__ ? 'pageHead' : '');
6
- /**
7
- * Returns the ref of the head config of current page
8
- */
9
- export const usePageHead = () => {
10
- const pageHead = inject(pageHeadSymbol);
11
- if (!pageHead) {
12
- throw new Error('usePageHead() is called without provider.');
13
- }
14
- return pageHead;
15
- };
@@ -1,17 +0,0 @@
1
- import type { ComputedRef, InjectionKey } from 'vue';
2
- /**
3
- * Page head title, which would be used as the content of `head > title` tag
4
- */
5
- export declare type PageHeadTitle = string;
6
- /**
7
- * Ref wrapper of `PageHeadTitle`
8
- */
9
- export declare type PageHeadTitleRef = ComputedRef<PageHeadTitle>;
10
- /**
11
- * Injection key for page head title
12
- */
13
- export declare const pageHeadTitleSymbol: InjectionKey<PageHeadTitleRef>;
14
- /**
15
- * Returns the ref of the head title of current page
16
- */
17
- export declare const usePageHeadTitle: () => PageHeadTitleRef;
@@ -1,15 +0,0 @@
1
- import { inject } from 'vue';
2
- /**
3
- * Injection key for page head title
4
- */
5
- export const pageHeadTitleSymbol = Symbol(__VUEPRESS_DEV__ ? 'pageHeadTitle' : '');
6
- /**
7
- * Returns the ref of the head title of current page
8
- */
9
- export const usePageHeadTitle = () => {
10
- const pageHeadTitle = inject(pageHeadTitleSymbol);
11
- if (!pageHeadTitle) {
12
- throw new Error('usePageHeadTitle() is called without provider.');
13
- }
14
- return pageHeadTitle;
15
- };
@@ -1,17 +0,0 @@
1
- import type { ComputedRef, InjectionKey } from 'vue';
2
- /**
3
- * Page language
4
- */
5
- export declare type PageLang = string;
6
- /**
7
- * Ref wrapper of `PageLang`
8
- */
9
- export declare type PageLangRef = ComputedRef<PageLang>;
10
- /**
11
- * Injection key for page language
12
- */
13
- export declare const pageLangSymbol: InjectionKey<PageLangRef>;
14
- /**
15
- * Returns the ref of the language of current page
16
- */
17
- export declare const usePageLang: () => PageLangRef;
@@ -1,15 +0,0 @@
1
- import { inject } from 'vue';
2
- /**
3
- * Injection key for page language
4
- */
5
- export const pageLangSymbol = Symbol(__VUEPRESS_DEV__ ? 'pageLang' : '');
6
- /**
7
- * Returns the ref of the language of current page
8
- */
9
- export const usePageLang = () => {
10
- const pageLang = inject(pageLangSymbol);
11
- if (!pageLang) {
12
- throw new Error('usePageLang() is called without provider.');
13
- }
14
- return pageLang;
15
- };
@@ -1,21 +0,0 @@
1
- import type { PageData } from '@vuepress/shared';
2
- import type { Ref } from 'vue';
3
- /**
4
- * Data resolvers of all pages
5
- *
6
- * The key is page key, and the value is an async function that
7
- * returns the page data
8
- */
9
- export declare type PagesData = Record<string, (() => Promise<PageData>) | undefined>;
10
- /**
11
- * Ref wrapper of `PagesData`
12
- */
13
- export declare type PagesDataRef = Ref<PagesData>;
14
- /**
15
- * Global pages data ref
16
- */
17
- export declare const pagesData: PagesDataRef;
18
- /**
19
- * Returns the ref of data resolvers of all pages
20
- */
21
- export declare const usePagesData: () => PagesDataRef;
@@ -1,10 +0,0 @@
1
- import { pagesData as pagesDataRaw } from '@internal/pagesData';
2
- import { ref } from 'vue';
3
- /**
4
- * Global pages data ref
5
- */
6
- export const pagesData = ref(pagesDataRaw);
7
- /**
8
- * Returns the ref of data resolvers of all pages
9
- */
10
- export const usePagesData = () => pagesData;
@@ -1,17 +0,0 @@
1
- import type { ComputedRef, InjectionKey } from 'vue';
2
- /**
3
- * Route locale path
4
- */
5
- export declare type RouteLocale = string;
6
- /**
7
- * Ref wrapper of `RouteLocale`
8
- */
9
- export declare type RouteLocaleRef = ComputedRef<RouteLocale>;
10
- /**
11
- * Injection key for page route locale path
12
- */
13
- export declare const routeLocaleSymbol: InjectionKey<RouteLocaleRef>;
14
- /**
15
- * Returns the ref of the route locale path of current page
16
- */
17
- export declare const useRouteLocale: () => RouteLocaleRef;
@@ -1,15 +0,0 @@
1
- import { inject } from 'vue';
2
- /**
3
- * Injection key for page route locale path
4
- */
5
- export const routeLocaleSymbol = Symbol(__VUEPRESS_DEV__ ? 'routeLocale' : '');
6
- /**
7
- * Returns the ref of the route locale path of current page
8
- */
9
- export const useRouteLocale = () => {
10
- const routeLocale = inject(routeLocaleSymbol);
11
- if (!routeLocale) {
12
- throw new Error('useRouteLocale() is called without provider.');
13
- }
14
- return routeLocale;
15
- };
@@ -1,15 +0,0 @@
1
- import type { SiteData } from '@vuepress/shared';
2
- import type { Ref } from 'vue';
3
- export type { SiteData };
4
- /**
5
- * Ref wrapper of `SiteData`
6
- */
7
- export declare type SiteDataRef = Ref<SiteData>;
8
- /**
9
- * Global site data ref
10
- */
11
- export declare const siteData: SiteDataRef;
12
- /**
13
- * Returns the ref of the site data
14
- */
15
- export declare const useSiteData: () => SiteDataRef;
@@ -1,16 +0,0 @@
1
- import { siteData as siteDataRaw } from '@internal/siteData';
2
- import { ref } from 'vue';
3
- /**
4
- * Global site data ref
5
- */
6
- export const siteData = ref(siteDataRaw);
7
- /**
8
- * Returns the ref of the site data
9
- */
10
- export const useSiteData = () => siteData;
11
- if (import.meta.webpackHot || import.meta.hot) {
12
- // reuse vue HMR runtime
13
- __VUE_HMR_RUNTIME__.updateSiteData = (data) => {
14
- siteData.value = data;
15
- };
16
- }
@@ -1,18 +0,0 @@
1
- import type { SiteData } from '@vuepress/shared';
2
- import type { ComputedRef, InjectionKey } from 'vue';
3
- /**
4
- * Site data of current locale
5
- */
6
- export declare type SiteLocaleData = SiteData;
7
- /**
8
- * Ref wrapper of `SiteLocaleData`
9
- */
10
- export declare type SiteLocaleDataRef = ComputedRef<SiteLocaleData>;
11
- /**
12
- * Injection key for site locale data
13
- */
14
- export declare const siteLocaleDataSymbol: InjectionKey<SiteLocaleDataRef>;
15
- /**
16
- * Returns the ref of the site data of current locale
17
- */
18
- export declare const useSiteLocaleData: () => SiteLocaleDataRef;
@@ -1,15 +0,0 @@
1
- import { inject } from 'vue';
2
- /**
3
- * Injection key for site locale data
4
- */
5
- export const siteLocaleDataSymbol = Symbol(__VUEPRESS_DEV__ ? 'siteLocaleData' : '');
6
- /**
7
- * Returns the ref of the site data of current locale
8
- */
9
- export const useSiteLocaleData = () => {
10
- const siteLocaleData = inject(siteLocaleDataSymbol);
11
- if (!siteLocaleData) {
12
- throw new Error('useSiteLocaleData() is called without provider.');
13
- }
14
- return siteLocaleData;
15
- };
@@ -1,13 +0,0 @@
1
- import type { InjectionKey } from 'vue';
2
- /**
3
- * A util function to force update `<head>` of current page
4
- */
5
- export declare type UpdateHead = () => void;
6
- /**
7
- * Injection key for `updateHead` util
8
- */
9
- export declare const updateHeadSymbol: InjectionKey<UpdateHead>;
10
- /**
11
- * Returns the `updateHead` util
12
- */
13
- export declare const useUpdateHead: () => UpdateHead;
@@ -1,15 +0,0 @@
1
- import { inject } from 'vue';
2
- /**
3
- * Injection key for `updateHead` util
4
- */
5
- export const updateHeadSymbol = Symbol(__VUEPRESS_DEV__ ? 'updateHead' : '');
6
- /**
7
- * Returns the `updateHead` util
8
- */
9
- export const useUpdateHead = () => {
10
- const updateHead = inject(updateHeadSymbol);
11
- if (!updateHead) {
12
- throw new Error('useUpdateHead() is called without provider.');
13
- }
14
- return updateHead;
15
- };
@@ -1,2 +0,0 @@
1
- import type { ClientAppEnhance } from '../types';
2
- export declare const defineClientAppEnhance: (clientAppEnhance: ClientAppEnhance) => ClientAppEnhance;
@@ -1 +0,0 @@
1
- export const defineClientAppEnhance = (clientAppEnhance) => clientAppEnhance;
@@ -1,2 +0,0 @@
1
- import type { ClientAppSetup } from '../types';
2
- export declare const defineClientAppSetup: (clientAppSetup: ClientAppSetup) => ClientAppSetup;
@@ -1 +0,0 @@
1
- export const defineClientAppSetup = (clientAppSetup) => clientAppSetup;
@@ -1,3 +0,0 @@
1
- export * from './defineClientAppEnhance';
2
- export * from './defineClientAppSetup';
3
- export * from './withBase';
@@ -1,3 +0,0 @@
1
- export * from './defineClientAppEnhance';
2
- export * from './defineClientAppSetup';
3
- export * from './withBase';
@@ -1,4 +0,0 @@
1
- /**
2
- * Prefix url with site base
3
- */
4
- export declare const withBase: (url: string) => string;
@@ -1,11 +0,0 @@
1
- import { isLinkHttp, removeLeadingSlash } from '@vuepress/shared';
2
- import { useSiteData } from '../composables';
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}${removeLeadingSlash(url)}`;
11
- };
package/lib/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export type { PageHeader } from '@vuepress/shared';
2
- export { RouterLink, useRoute, useRouter } from 'vue-router';
3
- export * from './components';
4
- export * from './composables';
5
- export * from './helpers';
6
- export * from './types';
7
- export * from './app';
8
- export * from './resolvers';
package/lib/index.js DELETED
@@ -1,7 +0,0 @@
1
- export { RouterLink, useRoute, useRouter } from 'vue-router';
2
- export * from './components';
3
- export * from './composables';
4
- export * from './helpers';
5
- export * from './types';
6
- export * from './app';
7
- export * from './resolvers';
@@ -1,15 +0,0 @@
1
- import type { PageData, PageFrontmatter, PageHead, PageHeadTitle, PageLang, RouteLocale, SiteData, SiteLocaleData } from './composables';
2
- /**
3
- * Resolver methods to get global computed
4
- *
5
- * Users can override corresponding method for advanced customization
6
- */
7
- export declare const resolvers: {
8
- resolvePageData: (pageKey: string) => Promise<PageData>;
9
- resolvePageFrontmatter: (pageData: PageData) => PageFrontmatter;
10
- resolvePageHead: (headTitle: PageHeadTitle, frontmatter: PageFrontmatter, siteLocale: SiteLocaleData) => PageHead;
11
- resolvePageHeadTitle: (page: PageData, siteLocale: SiteLocaleData) => PageHeadTitle;
12
- resolvePageLang: (pageData: PageData) => PageLang;
13
- resolveRouteLocale: (locales: SiteData['locales'], routePath: string) => RouteLocale;
14
- resolveSiteLocaleData: (site: SiteData, routeLocale: RouteLocale) => SiteLocaleData;
15
- };
package/lib/resolvers.js DELETED
@@ -1,64 +0,0 @@
1
- import { dedupeHead, isArray, isString, resolveLocalePath, } from '@vuepress/shared';
2
- import { reactive } from 'vue';
3
- import { pageDataEmpty, pagesData } from './composables';
4
- /**
5
- * Resolver methods to get global computed
6
- *
7
- * Users can override corresponding method for advanced customization
8
- */
9
- export const resolvers = reactive({
10
- /**
11
- * Resolve page data according to page key
12
- */
13
- resolvePageData: async (pageKey) => {
14
- const pageDataResolver = pagesData.value[pageKey];
15
- const pageData = await (pageDataResolver === null || pageDataResolver === void 0 ? void 0 : pageDataResolver());
16
- return pageData !== null && pageData !== void 0 ? pageData : pageDataEmpty;
17
- },
18
- /**
19
- * Resolve page frontmatter from page data
20
- */
21
- resolvePageFrontmatter: (pageData) => pageData.frontmatter,
22
- /**
23
- * Merge the head config in frontmatter and site locale
24
- *
25
- * Frontmatter should take priority over site locale
26
- */
27
- resolvePageHead: (headTitle, frontmatter, siteLocale) => {
28
- const description = isString(frontmatter.description)
29
- ? frontmatter.description
30
- : siteLocale.description;
31
- const head = [
32
- ...(isArray(frontmatter.head) ? frontmatter.head : []),
33
- ...siteLocale.head,
34
- ['title', {}, headTitle],
35
- ['meta', { name: 'description', content: description }],
36
- ];
37
- return dedupeHead(head);
38
- },
39
- /**
40
- * Resolve the content of page head title
41
- *
42
- * It would be used as the content of the `<title>` tag
43
- */
44
- resolvePageHeadTitle: (page, siteLocale) => `${page.title ? `${page.title} | ` : ``}${siteLocale.title}`,
45
- /**
46
- * Resolve page language from page data
47
- *
48
- * It would be used as the `lang` attribute of `<html>` tag
49
- */
50
- resolvePageLang: (pageData) => pageData.lang || 'en',
51
- /**
52
- * Resolve locale path according to route path and locales config
53
- */
54
- resolveRouteLocale: (locales, routePath) => resolveLocalePath(locales, routePath),
55
- /**
56
- * Resolve site data for specific locale
57
- *
58
- * It would merge the locales fields to the root fields
59
- */
60
- resolveSiteLocaleData: (site, routeLocale) => ({
61
- ...site,
62
- ...site.locales[routeLocale],
63
- }),
64
- });
package/lib/router.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import type { Router } from 'vue-router';
2
- /**
3
- * Create vue-router instance
4
- */
5
- export declare const createVueRouter: () => Router;
package/lib/router.js DELETED
@@ -1,40 +0,0 @@
1
- import { pagesComponents } from '@internal/pagesComponents';
2
- import { pagesRoutes } from '@internal/pagesRoutes';
3
- import { removeEndingSlash } from '@vuepress/shared';
4
- import { createMemoryHistory, createRouter, createWebHistory, START_LOCATION, } from 'vue-router';
5
- import { pageData, siteData } from './composables';
6
- import { resolvers } from './resolvers';
7
- /**
8
- * - use `createWebHistory` in dev mode and build mode client bundle
9
- * - use `createMemoryHistory` in build mode server bundle
10
- */
11
- const historyCreator = __VUEPRESS_SSR__ ? createMemoryHistory : createWebHistory;
12
- /**
13
- * Create vue-router instance
14
- */
15
- export const createVueRouter = () => {
16
- const router = createRouter({
17
- // TODO: it might be an issue of vue-router that have to remove the ending slash
18
- history: historyCreator(removeEndingSlash(siteData.value.base)),
19
- routes: pagesRoutes,
20
- scrollBehavior: (to, from, savedPosition) => {
21
- if (savedPosition)
22
- return savedPosition;
23
- if (to.hash)
24
- return { el: to.hash };
25
- return { top: 0 };
26
- },
27
- });
28
- router.beforeResolve(async (to, from) => {
29
- var _a;
30
- if (to.path !== from.path || from === START_LOCATION) {
31
- // ensure page data and page component have been loaded
32
- ;
33
- [pageData.value] = await Promise.all([
34
- resolvers.resolvePageData(to.name),
35
- (_a = pagesComponents[to.name]) === null || _a === void 0 ? void 0 : _a.__asyncLoader(),
36
- ]);
37
- }
38
- });
39
- return router;
40
- };
@@ -1,3 +0,0 @@
1
- import type { App } from 'vue';
2
- import type { GlobalComputed } from './setupGlobalComputed';
3
- export declare const setupDevtools: (app: App, globalComputed: GlobalComputed) => void;
@@ -1,22 +0,0 @@
1
- import { setupDevtoolsPlugin } from '@vue/devtools-api';
2
- export const setupDevtools = (app, globalComputed) => {
3
- setupDevtoolsPlugin({
4
- // fix recursive reference
5
- app: app,
6
- id: 'org.vuejs.vuepress',
7
- label: 'VuePress',
8
- packageName: '@vuepress/client',
9
- homepage: 'https://v2.vuepress.vuejs.org',
10
- logo: 'https://v2.vuepress.vuejs.org/images/hero.png',
11
- componentStateTypes: ['VuePress'],
12
- }, (api) => {
13
- api.on.inspectComponent((payload) => {
14
- payload.instanceData.state.push(...Object.entries(globalComputed).map(([name, item]) => ({
15
- type: 'VuePress',
16
- key: name,
17
- editable: false,
18
- value: item.value,
19
- })));
20
- });
21
- });
22
- };
@@ -1,5 +0,0 @@
1
- import type { App } from 'vue';
2
- /**
3
- * Register global built-in components
4
- */
5
- export declare const setupGlobalComponents: (app: App) => void;
@@ -1,10 +0,0 @@
1
- import { ClientOnly, Content } from './components';
2
- /**
3
- * Register global built-in components
4
- */
5
- export const setupGlobalComponents = (app) => {
6
- /* eslint-disable vue/match-component-file-name */
7
- app.component('ClientOnly', ClientOnly);
8
- app.component('Content', Content);
9
- /* eslint-enable vue/match-component-file-name */
10
- };
@@ -1,34 +0,0 @@
1
- import type { App } from 'vue';
2
- import type { Router } from 'vue-router';
3
- import type { PageData, PageDataRef, PageFrontmatter, PageFrontmatterRef, PageHead, PageHeadRef, PageHeadTitle, PageHeadTitleRef, PageLang, PageLangRef, RouteLocale, RouteLocaleRef, SiteData, SiteDataRef, SiteLocaleData, SiteLocaleDataRef } from './composables';
4
- import { withBase } from './helpers';
5
- /**
6
- * Vuepress client global computed
7
- */
8
- export interface GlobalComputed {
9
- pageData: PageDataRef;
10
- pageFrontmatter: PageFrontmatterRef;
11
- pageHead: PageHeadRef;
12
- pageHeadTitle: PageHeadTitleRef;
13
- pageLang: PageLangRef;
14
- routeLocale: RouteLocaleRef;
15
- siteData: SiteDataRef;
16
- siteLocaleData: SiteLocaleDataRef;
17
- }
18
- /**
19
- * Create and provide global computed
20
- */
21
- export declare const setupGlobalComputed: (app: App, router: Router) => GlobalComputed;
22
- declare module '@vue/runtime-core' {
23
- interface ComponentCustomProperties {
24
- $frontmatter: PageFrontmatter;
25
- $head: PageHead;
26
- $headTitle: PageHeadTitle;
27
- $lang: PageLang;
28
- $page: PageData;
29
- $routeLocale: RouteLocale;
30
- $site: SiteData;
31
- $siteLocale: SiteLocaleData;
32
- $withBase: typeof withBase;
33
- }
34
- }
@@ -1,45 +0,0 @@
1
- import { computed } from 'vue';
2
- import { pageData, pageFrontmatterSymbol, pageHeadSymbol, pageHeadTitleSymbol, pageLangSymbol, routeLocaleSymbol, siteData, siteLocaleDataSymbol, } from './composables';
3
- import { withBase } from './helpers';
4
- import { resolvers } from './resolvers';
5
- /**
6
- * Create and provide global computed
7
- */
8
- export const setupGlobalComputed = (app, router) => {
9
- // create global computed
10
- const routeLocale = computed(() => resolvers.resolveRouteLocale(siteData.value.locales, router.currentRoute.value.path));
11
- const siteLocaleData = computed(() => resolvers.resolveSiteLocaleData(siteData.value, routeLocale.value));
12
- const pageFrontmatter = computed(() => resolvers.resolvePageFrontmatter(pageData.value));
13
- const pageHeadTitle = computed(() => resolvers.resolvePageHeadTitle(pageData.value, siteLocaleData.value));
14
- const pageHead = computed(() => resolvers.resolvePageHead(pageHeadTitle.value, pageFrontmatter.value, siteLocaleData.value));
15
- const pageLang = computed(() => resolvers.resolvePageLang(pageData.value));
16
- // provide global computed
17
- app.provide(routeLocaleSymbol, routeLocale);
18
- app.provide(siteLocaleDataSymbol, siteLocaleData);
19
- app.provide(pageFrontmatterSymbol, pageFrontmatter);
20
- app.provide(pageHeadTitleSymbol, pageHeadTitle);
21
- app.provide(pageHeadSymbol, pageHead);
22
- app.provide(pageLangSymbol, pageLang);
23
- // provide global helpers
24
- Object.defineProperties(app.config.globalProperties, {
25
- $frontmatter: { get: () => pageFrontmatter.value },
26
- $head: { get: () => pageHead.value },
27
- $headTitle: { get: () => pageHeadTitle.value },
28
- $lang: { get: () => pageLang.value },
29
- $page: { get: () => pageData.value },
30
- $routeLocale: { get: () => routeLocale.value },
31
- $site: { get: () => siteData.value },
32
- $siteLocale: { get: () => siteLocaleData.value },
33
- $withBase: { get: () => withBase },
34
- });
35
- return {
36
- pageData,
37
- pageFrontmatter,
38
- pageHead,
39
- pageHeadTitle,
40
- pageLang,
41
- routeLocale,
42
- siteData,
43
- siteLocaleData,
44
- };
45
- };
@@ -1,13 +0,0 @@
1
- import type { HeadConfig } from '@vuepress/shared';
2
- /**
3
- * Auto update head and provide as global util
4
- */
5
- export declare const setupUpdateHead: () => void;
6
- /**
7
- * Query the matched head tag of head config
8
- */
9
- export declare const queryHeadTag: ([tagName, attrs, content,]: HeadConfig) => HTMLElement | null;
10
- /**
11
- * Create head tag from head config
12
- */
13
- export declare const createHeadTag: ([tagName, attrs, content,]: HeadConfig) => HTMLElement | null;