File tree 4 files changed +18
-10
lines changed
4 files changed +18
-10
lines changed Original file line number Diff line number Diff line change 1
1
import { defineComponent , h } from 'vue'
2
- import { useRoute } from '../router '
2
+ import { useData , useRoute } from 'vitepress '
3
3
import { contentUpdatedCallbacks } from '../utils'
4
4
5
5
const runCbs = ( ) => contentUpdatedCallbacks . forEach ( ( fn ) => fn ( ) )
@@ -11,14 +11,19 @@ export const Content = defineComponent({
11
11
} ,
12
12
setup ( props ) {
13
13
const route = useRoute ( )
14
+ const { site } = useData ( )
14
15
return ( ) =>
15
- h ( props . as , { style : { position : 'relative' } } , [
16
- route . component
17
- ? h ( route . component , {
18
- onVnodeMounted : runCbs ,
19
- onVnodeUpdated : runCbs
20
- } )
21
- : '404 Page Not Found'
22
- ] )
16
+ h (
17
+ props . as ,
18
+ site . value . contentProps ?? { style : { position : 'relative' } } ,
19
+ [
20
+ route . component
21
+ ? h ( route . component , {
22
+ onVnodeMounted : runCbs ,
23
+ onVnodeUpdated : runCbs
24
+ } )
25
+ : '404 Page Not Found'
26
+ ]
27
+ )
23
28
}
24
29
} )
Original file line number Diff line number Diff line change @@ -235,7 +235,8 @@ export async function resolveSiteData(
235
235
themeConfig : userConfig . themeConfig || { } ,
236
236
locales : userConfig . locales || { } ,
237
237
scrollOffset : userConfig . scrollOffset ?? 90 ,
238
- cleanUrls : ! ! userConfig . cleanUrls
238
+ cleanUrls : ! ! userConfig . cleanUrls ,
239
+ contentProps : userConfig . contentProps
239
240
}
240
241
}
241
242
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ export interface UserConfig<ThemeConfig = any>
70
70
71
71
appearance ?: boolean | 'dark'
72
72
lastUpdated ?: boolean
73
+ contentProps ?: Record < string , any >
73
74
74
75
/**
75
76
* MarkdownIt options
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ export interface SiteData<ThemeConfig = any> {
60
60
scrollOffset : number | string | string [ ]
61
61
locales : LocaleConfig < ThemeConfig >
62
62
localeIndex ?: string
63
+ contentProps ?: Record < string , any >
63
64
}
64
65
65
66
export type HeadConfig =
You can’t perform that action at this time.
0 commit comments