Skip to content

Commit

Permalink
feat: allow passing fast glob options to createContentLoader
Browse files Browse the repository at this point in the history
closes #2985
  • Loading branch information
brc-dd committed Sep 19, 2023
1 parent 5bb6bb0 commit 4f9a60b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/node/contentLoader.ts
Expand Up @@ -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 {
Expand All @@ -72,7 +79,8 @@ export function createContentLoader<T = ContentData[]>(
includeSrc,
render,
excerpt: renderExcerpt,
transform
transform,
globOptions
}: ContentOptions<T> = {}
): {
watch: string | string[]
Expand Down Expand Up @@ -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()
}
Expand Down

0 comments on commit 4f9a60b

Please sign in to comment.