Skip to content

Commit 21457a2

Browse files
authored
Merge branch 'main' into main
2 parents ca5ac6f + 318c14f commit 21457a2

File tree

6 files changed

+26
-14
lines changed

6 files changed

+26
-14
lines changed

__tests__/e2e/dynamic-routes/[id].paths.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default defineRoutes({
66
// console.log('watchedFiles', watchedFiles)
77
return paths
88
},
9-
watch: ['**/data-loading/**/*.json'],
9+
watch: ['../data-loading/**/*.json'],
1010
async transformPageData(pageData) {
1111
// console.log('transformPageData', pageData.filePath)
1212
pageData.title += ' - transformed'

src/node/contentLoader.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ export function createContentLoader<T = ContentData[]>(
9595

9696
async load(files?: string[]) {
9797
// the loader is being called directly, do a fresh glob
98-
files = files ?? (await glob(watch, options.globOptions))
98+
files ??= await glob(watch, {
99+
absolute: true,
100+
...options.globOptions
101+
})
99102

100103
const md = await createMarkdownRenderer(
101104
config.srcDir,

src/node/plugins/dynamicRoutesPlugin.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,10 @@ async function resolveDynamicRoutes(
308308
let pathsData: UserRouteConfig[]
309309

310310
if (typeof loader === 'function') {
311-
const watchedFiles = await glob(watch, options.globOptions)
311+
const watchedFiles = await glob(watch, {
312+
absolute: true,
313+
...options.globOptions
314+
})
312315
pathsData = await loader(watchedFiles)
313316
} else {
314317
pathsData = loader

src/node/plugins/staticDataPlugin.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ export const staticDataPlugin: Plugin = {
9797
}
9898

9999
// load the data
100-
const watchedFiles = await glob(watch, options.globOptions)
100+
const watchedFiles = await glob(watch, {
101+
absolute: true,
102+
...options.globOptions
103+
})
101104
const data = await load(watchedFiles)
102105

103106
// record loader module for HMR

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
}

src/node/utils/glob.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { glob as _glob } from 'tinyglobby'
33
import { normalizePath } from 'vite'
44

55
export interface GlobOptions {
6+
absolute?: boolean
67
cwd?: string
78
ignore?: string | string[]
89
dot?: boolean

0 commit comments

Comments
 (0)