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) // console.log('watchedFiles', watchedFiles)
return paths return paths
}, },
watch: ['**/data-loading/**/*.json'], watch: ['../data-loading/**/*.json'],
async transformPageData(pageData) { async transformPageData(pageData) {
// console.log('transformPageData', pageData.filePath) // console.log('transformPageData', pageData.filePath)
pageData.title += ' - transformed' pageData.title += ' - transformed'

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

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

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

@ -23,9 +23,9 @@ export type RawConfigExports<ThemeConfig = any> =
| Awaitable<UserConfig<ThemeConfig>> | Awaitable<UserConfig<ThemeConfig>>
| (() => Awaitable<UserConfig<ThemeConfig>>) | (() => Awaitable<UserConfig<ThemeConfig>>)
export interface TransformContext { export interface TransformContext<ThemeConfig = any> {
page: string page: string
siteConfig: SiteConfig siteConfig: SiteConfig<ThemeConfig>
siteData: SiteData siteData: SiteData
pageData: PageData pageData: PageData
title: string title: string
@ -35,8 +35,8 @@ export interface TransformContext {
assets: string[] assets: string[]
} }
export interface TransformPageContext { export interface TransformPageContext<ThemeConfig = any> {
siteConfig: SiteConfig siteConfig: SiteConfig<ThemeConfig>
} }
export interface UserConfig<ThemeConfig = any> export interface UserConfig<ThemeConfig = any>
@ -161,7 +161,7 @@ export interface UserConfig<ThemeConfig = any>
* Build end hook: called when SSG finish. * Build end hook: called when SSG finish.
* @param siteConfig The resolved configuration. * @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. * 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. * 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. * HTML transform hook: runs before writing HTML to dist.
@ -181,7 +183,7 @@ export interface UserConfig<ThemeConfig = any>
transformHtml?: ( transformHtml?: (
code: string, code: string,
id: string, id: string,
ctx: TransformContext ctx: TransformContext<ThemeConfig>
) => Awaitable<string | void> ) => Awaitable<string | void>
/** /**
@ -189,7 +191,7 @@ export interface UserConfig<ThemeConfig = any>
*/ */
transformPageData?: ( transformPageData?: (
pageData: PageData, pageData: PageData,
ctx: TransformPageContext ctx: TransformPageContext<ThemeConfig>
) => Awaitable<Partial<PageData> | { [key: string]: any } | void> ) => Awaitable<Partial<PageData> | { [key: string]: any } | void>
/** /**
@ -207,7 +209,7 @@ export interface UserConfig<ThemeConfig = any>
export interface SiteConfig<ThemeConfig = any> export interface SiteConfig<ThemeConfig = any>
extends Pick< extends Pick<
UserConfig, UserConfig<ThemeConfig>,
| 'markdown' | 'markdown'
| 'vue' | 'vue'
| 'vite' | 'vite'
@ -243,6 +245,6 @@ export interface SiteConfig<ThemeConfig = any>
inv: Record<string, string | undefined> inv: Record<string, string | undefined>
} }
logger: Logger logger: Logger
userConfig: UserConfig userConfig: UserConfig<ThemeConfig>
buildConcurrency: number buildConcurrency: number
} }

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

Loading…
Cancel
Save