Skip to content

Commit

Permalink
type: support specifying themeConfig type for useData() via generics
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 16, 2021
1 parent ff4fa62 commit 3fed6f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/client/app/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { withBase } from './utils'

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

export interface VitePressData {
site: Ref<SiteData>
export interface VitePressData<T = any> {
site: Ref<SiteData<T>>
page: Ref<PageData>
theme: Ref<any>
theme: Ref<T>
frontmatter: Ref<PageData['frontmatter']>
title: Ref<string>
description: Ref<string>
Expand Down Expand Up @@ -61,7 +61,7 @@ export function initData(route: Route): VitePressData {
}
}

export function useData(): VitePressData {
export function useData<T = any>(): VitePressData<T> {
const data = inject(dataSymbol)
if (!data) {
throw new Error('vitepress data not properly injected in app')
Expand Down

0 comments on commit 3fed6f9

Please sign in to comment.