fix(types): pass generics deeply to user config

pull/4898/merge
Divyansh Singh 1 month ago
parent 300dea4aad
commit 777e2caaac

@ -23,9 +23,9 @@ export type RawConfigExports<ThemeConfig = any> =
| Awaitable<UserConfig<ThemeConfig>>
| (() => Awaitable<UserConfig<ThemeConfig>>)
export interface TransformContext {
export interface TransformContext<ThemeConfig = any> {
page: string
siteConfig: SiteConfig
siteConfig: SiteConfig<ThemeConfig>
siteData: SiteData
pageData: PageData
title: string
@ -35,8 +35,8 @@ export interface TransformContext {
assets: string[]
}
export interface TransformPageContext {
siteConfig: SiteConfig
export interface TransformPageContext<ThemeConfig = any> {
siteConfig: SiteConfig<ThemeConfig>
}
export interface UserConfig<ThemeConfig = any>
@ -161,7 +161,7 @@ export interface UserConfig<ThemeConfig = any>
* Build end hook: called when SSG finish.
* @param siteConfig The resolved configuration.
*/
buildEnd?: (siteConfig: SiteConfig) => Awaitable<void>
buildEnd?: (siteConfig: SiteConfig<ThemeConfig>) => Awaitable<void>
/**
* Render end hook: called when SSR rendering is done.
@ -173,7 +173,9 @@ export interface UserConfig<ThemeConfig = any>
*
* This build hook will allow you to modify the head adding new entries that cannot be statically added.
*/
transformHead?: (context: TransformContext) => Awaitable<HeadConfig[] | void>
transformHead?: (
ctx: TransformContext<ThemeConfig>
) => Awaitable<HeadConfig[] | void>
/**
* HTML transform hook: runs before writing HTML to dist.
@ -181,7 +183,7 @@ export interface UserConfig<ThemeConfig = any>
transformHtml?: (
code: string,
id: string,
ctx: TransformContext
ctx: TransformContext<ThemeConfig>
) => Awaitable<string | void>
/**
@ -189,7 +191,7 @@ export interface UserConfig<ThemeConfig = any>
*/
transformPageData?: (
pageData: PageData,
ctx: TransformPageContext
ctx: TransformPageContext<ThemeConfig>
) => Awaitable<Partial<PageData> | { [key: string]: any } | void>
/**
@ -207,7 +209,7 @@ export interface UserConfig<ThemeConfig = any>
export interface SiteConfig<ThemeConfig = any>
extends Pick<
UserConfig,
UserConfig<ThemeConfig>,
| 'markdown'
| 'vue'
| 'vite'
@ -243,6 +245,6 @@ export interface SiteConfig<ThemeConfig = any>
inv: Record<string, string | undefined>
}
logger: Logger
userConfig: UserConfig
userConfig: UserConfig<ThemeConfig>
buildConcurrency: number
}

Loading…
Cancel
Save