Skip to content

Commit 777e2ca

Browse files
committed
fix(types): pass generics deeply to user config
1 parent 300dea4 commit 777e2ca

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/node/siteConfig.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ export type RawConfigExports<ThemeConfig = any> =
2323
| Awaitable<UserConfig<ThemeConfig>>
2424
| (() => Awaitable<UserConfig<ThemeConfig>>)
2525

26-
export interface TransformContext {
26+
export interface TransformContext<ThemeConfig = any> {
2727
page: string
28-
siteConfig: SiteConfig
28+
siteConfig: SiteConfig<ThemeConfig>
2929
siteData: SiteData
3030
pageData: PageData
3131
title: string
@@ -35,8 +35,8 @@ export interface TransformContext {
3535
assets: string[]
3636
}
3737

38-
export interface TransformPageContext {
39-
siteConfig: SiteConfig
38+
export interface TransformPageContext<ThemeConfig = any> {
39+
siteConfig: SiteConfig<ThemeConfig>
4040
}
4141

4242
export interface UserConfig<ThemeConfig = any>
@@ -161,7 +161,7 @@ export interface UserConfig<ThemeConfig = any>
161161
* Build end hook: called when SSG finish.
162162
* @param siteConfig The resolved configuration.
163163
*/
164-
buildEnd?: (siteConfig: SiteConfig) => Awaitable<void>
164+
buildEnd?: (siteConfig: SiteConfig<ThemeConfig>) => Awaitable<void>
165165

166166
/**
167167
* Render end hook: called when SSR rendering is done.
@@ -173,23 +173,25 @@ export interface UserConfig<ThemeConfig = any>
173173
*
174174
* This build hook will allow you to modify the head adding new entries that cannot be statically added.
175175
*/
176-
transformHead?: (context: TransformContext) => Awaitable<HeadConfig[] | void>
176+
transformHead?: (
177+
ctx: TransformContext<ThemeConfig>
178+
) => Awaitable<HeadConfig[] | void>
177179

178180
/**
179181
* HTML transform hook: runs before writing HTML to dist.
180182
*/
181183
transformHtml?: (
182184
code: string,
183185
id: string,
184-
ctx: TransformContext
186+
ctx: TransformContext<ThemeConfig>
185187
) => Awaitable<string | void>
186188

187189
/**
188190
* PageData transform hook: runs when rendering markdown to vue
189191
*/
190192
transformPageData?: (
191193
pageData: PageData,
192-
ctx: TransformPageContext
194+
ctx: TransformPageContext<ThemeConfig>
193195
) => Awaitable<Partial<PageData> | { [key: string]: any } | void>
194196

195197
/**
@@ -207,7 +209,7 @@ export interface UserConfig<ThemeConfig = any>
207209

208210
export interface SiteConfig<ThemeConfig = any>
209211
extends Pick<
210-
UserConfig,
212+
UserConfig<ThemeConfig>,
211213
| 'markdown'
212214
| 'vue'
213215
| 'vite'
@@ -243,6 +245,6 @@ export interface SiteConfig<ThemeConfig = any>
243245
inv: Record<string, string | undefined>
244246
}
245247
logger: Logger
246-
userConfig: UserConfig
248+
userConfig: UserConfig<ThemeConfig>
247249
buildConcurrency: number
248250
}

0 commit comments

Comments
 (0)