@@ -19,19 +19,45 @@ import {
1919} from './composables'
2020import type {
2121 PageData ,
22+ PageDataRef ,
2223 PageFrontmatter ,
24+ PageFrontmatterRef ,
25+ PageHead ,
26+ PageHeadRef ,
2327 PageHeadTitle ,
28+ PageHeadTitleRef ,
2429 PageLang ,
30+ PageLangRef ,
2531 RouteLocale ,
32+ RouteLocaleRef ,
2633 SiteData ,
34+ SiteDataRef ,
2735 SiteLocaleData ,
36+ SiteLocaleDataRef ,
2837} from './composables'
2938import { withBase } from './utils'
3039
40+ /**
41+ * Vuepress client global computed
42+ */
43+ export interface GlobalComputed {
44+ pageData : PageDataRef
45+ pageFrontmatter : PageFrontmatterRef
46+ pageHead : PageHeadRef
47+ pageHeadTitle : PageHeadTitleRef
48+ pageLang : PageLangRef
49+ routeLocale : RouteLocaleRef
50+ siteData : SiteDataRef
51+ siteLocaleData : SiteLocaleDataRef
52+ }
53+
3154/**
3255 * Create and provide global computed
3356 */
34- export const provideGlobalComputed = ( app : App , router : Router ) : void => {
57+ export const provideGlobalComputed = (
58+ app : App ,
59+ router : Router
60+ ) : GlobalComputed => {
3561 // create global computed
3662 const routeLocale = computed ( ( ) =>
3763 resolveRouteLocale ( siteData . value . locales , router . currentRoute . value . path )
@@ -63,6 +89,7 @@ export const provideGlobalComputed = (app: App, router: Router): void => {
6389 // provide global helpers
6490 Object . defineProperties ( app . config . globalProperties , {
6591 $frontmatter : { get : ( ) => pageFrontmatter . value } ,
92+ $head : { get : ( ) => pageHead . value } ,
6693 $headTitle : { get : ( ) => pageHeadTitle . value } ,
6794 $lang : { get : ( ) => pageLang . value } ,
6895 $page : { get : ( ) => pageData . value } ,
@@ -71,11 +98,23 @@ export const provideGlobalComputed = (app: App, router: Router): void => {
7198 $siteLocale : { get : ( ) => siteLocaleData . value } ,
7299 $withBase : { get : ( ) => withBase } ,
73100 } )
101+
102+ return {
103+ pageData,
104+ pageFrontmatter,
105+ pageHead,
106+ pageHeadTitle,
107+ pageLang,
108+ routeLocale,
109+ siteData,
110+ siteLocaleData,
111+ }
74112}
75113
76114declare module '@vue/runtime-core' {
77115 export interface ComponentCustomProperties {
78116 $frontmatter : PageFrontmatter
117+ $head : PageHead
79118 $headTitle : PageHeadTitle
80119 $lang : PageLang
81120 $page : PageData
0 commit comments