File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
packages/@vuepress/client/src/injections Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -3,18 +3,22 @@ import type { ComputedRef, InjectionKey } from 'vue'
3
3
import type { PageData , PageFrontmatter } from '@vuepress/shared'
4
4
5
5
export type { PageFrontmatter }
6
- export type PageFrontmatterRef = ComputedRef < PageFrontmatter >
6
+ export type PageFrontmatterRef <
7
+ T extends Record < any , any > = Record < string , unknown >
8
+ > = ComputedRef < PageFrontmatter < T > >
7
9
8
10
export const pageFrontmatterSymbol : InjectionKey < PageFrontmatterRef > = Symbol (
9
11
__DEV__ ? 'pageFrontmatter' : ''
10
12
)
11
13
12
- export const usePageFrontmatter = ( ) : PageFrontmatterRef => {
14
+ export const usePageFrontmatter = <
15
+ T extends Record < any , any > = Record < string , unknown >
16
+ > ( ) : PageFrontmatterRef < T > => {
13
17
const pageFrontmatter = inject ( pageFrontmatterSymbol )
14
18
if ( ! pageFrontmatter ) {
15
19
throw new Error ( 'usePageFrontmatter() is called without provider.' )
16
20
}
17
- return pageFrontmatter
21
+ return pageFrontmatter as PageFrontmatterRef < T >
18
22
}
19
23
20
24
export const resolvePageFrontmatter = ( pageData : PageData ) : PageFrontmatter =>
You can’t perform that action at this time.
0 commit comments