Skip to content

Commit 3fed6f9

Browse files
committed
type: support specifying themeConfig type for useData() via generics
1 parent ff4fa62 commit 3fed6f9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/client/app/data.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import { withBase } from './utils'
66

77
export const dataSymbol: InjectionKey<VitePressData> = Symbol()
88

9-
export interface VitePressData {
10-
site: Ref<SiteData>
9+
export interface VitePressData<T = any> {
10+
site: Ref<SiteData<T>>
1111
page: Ref<PageData>
12-
theme: Ref<any>
12+
theme: Ref<T>
1313
frontmatter: Ref<PageData['frontmatter']>
1414
title: Ref<string>
1515
description: Ref<string>
@@ -61,7 +61,7 @@ export function initData(route: Route): VitePressData {
6161
}
6262
}
6363

64-
export function useData(): VitePressData {
64+
export function useData<T = any>(): VitePressData<T> {
6565
const data = inject(dataSymbol)
6666
if (!data) {
6767
throw new Error('vitepress data not properly injected in app')

0 commit comments

Comments
 (0)