feat: allow passing fast glob options to `createContentLoader`

closes #2985
fix/2989
Divyansh Singh 1 year ago
parent 5bb6bb0a14
commit 4f9a60b0cf

@ -49,6 +49,13 @@ export interface ContentOptions<T = ContentData[]> {
* bundle if imported from components or markdown files.
*/
transform?: (data: ContentData[]) => T | Promise<T>
/**
* Options to pass to `fast-glob`.
* You'll need to manually specify `node_modules` and `dist` in
* `globOptions.ignore` if you've overridden it.
*/
globOptions?: glob.Options
}
export interface ContentData {
@ -72,7 +79,8 @@ export function createContentLoader<T = ContentData[]>(
includeSrc,
render,
excerpt: renderExcerpt,
transform
transform,
globOptions
}: ContentOptions<T> = {}
): {
watch: string | string[]
@ -106,7 +114,8 @@ export function createContentLoader<T = ContentData[]>(
// the loader is being called directly, do a fresh glob
files = (
await glob(pattern, {
ignore: ['**/node_modules/**', '**/dist/**']
ignore: ['**/node_modules/**', '**/dist/**'],
...globOptions
})
).sort()
}

Loading…
Cancel
Save