Merge branch 'main' into main

pull/4893/head
Evorp 1 month ago committed by GitHub
commit 21457a2875
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -6,7 +6,7 @@ export default defineRoutes({
// console.log('watchedFiles', watchedFiles)
return paths
},
watch: ['**/data-loading/**/*.json'],
watch: ['../data-loading/**/*.json'],
async transformPageData(pageData) {
// console.log('transformPageData', pageData.filePath)
pageData.title += ' - transformed'

@ -95,7 +95,10 @@ export function createContentLoader<T = ContentData[]>(
async load(files?: string[]) {
// the loader is being called directly, do a fresh glob
files = files ?? (await glob(watch, options.globOptions))
files ??= await glob(watch, {
absolute: true,
...options.globOptions
})
const md = await createMarkdownRenderer(
config.srcDir,

@ -308,7 +308,10 @@ async function resolveDynamicRoutes(
let pathsData: UserRouteConfig[]
if (typeof loader === 'function') {
const watchedFiles = await glob(watch, options.globOptions)
const watchedFiles = await glob(watch, {
absolute: true,
...options.globOptions
})
pathsData = await loader(watchedFiles)
} else {
pathsData = loader

@ -97,7 +97,10 @@ export const staticDataPlugin: Plugin = {
}
// load the data
const watchedFiles = await glob(watch, options.globOptions)
const watchedFiles = await glob(watch, {
absolute: true,
...options.globOptions
})
const data = await load(watchedFiles)
// record loader module for HMR

@ -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
}

@ -3,6 +3,7 @@ import { glob as _glob } from 'tinyglobby'
import { normalizePath } from 'vite'
export interface GlobOptions {
absolute?: boolean
cwd?: string
ignore?: string | string[]
dot?: boolean

Loading…
Cancel
Save