From 4f9a60b0cfa2fa841465f6e8cc5f77ed3e023817 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Tue, 19 Sep 2023 23:04:40 +0530 Subject: [PATCH] feat: allow passing fast glob options to `createContentLoader` closes #2985 --- src/node/contentLoader.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/node/contentLoader.ts b/src/node/contentLoader.ts index 228d83a5..6eaf8be6 100644 --- a/src/node/contentLoader.ts +++ b/src/node/contentLoader.ts @@ -49,6 +49,13 @@ export interface ContentOptions { * bundle if imported from components or markdown files. */ transform?: (data: ContentData[]) => T | Promise + + /** + * 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( includeSrc, render, excerpt: renderExcerpt, - transform + transform, + globOptions }: ContentOptions = {} ): { watch: string | string[] @@ -106,7 +114,8 @@ export function createContentLoader( // the loader is being called directly, do a fresh glob files = ( await glob(pattern, { - ignore: ['**/node_modules/**', '**/dist/**'] + ignore: ['**/node_modules/**', '**/dist/**'], + ...globOptions }) ).sort() }