Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support fast-glob options in createContentLoader #2985

Closed
4 tasks done
huluobotx opened this issue Sep 19, 2023 · 3 comments
Closed
4 tasks done

Support fast-glob options in createContentLoader #2985

huluobotx opened this issue Sep 19, 2023 · 3 comments

Comments

@huluobotx
Copy link
Contributor

Is your feature request related to a problem? Please describe.

I want to ignore some files and folders, especially in the srcExclude configuration, but I cannot pass fast global options.

Describe the solution you'd like

The parameters of createContentLoader only support strings and arrays. hope it support objects to pass fast global options

Describe alternatives you've considered

No response

Additional context

No response

Validations

@brc-dd
Copy link
Member

brc-dd commented Sep 19, 2023

As I mentioned on your PR won't this work? #2963 (comment)

@huluobotx
Copy link
Contributor Author

As I mentioned on your PR won't this work? #2963 (comment)

I have tried using negative patterns, and in some cases it works and in others it doesn't, especially when using './' as the starting path and excluding both files and folders.
Use fast-glob options is easy to implement my require.

const excludeDirs = exclude_dir && exclude_dir.length > 0 ? ('/**/!(' + exclude_dir.join('|') + ')/') : '/'
const excludeDirs2 = exclude_dir && exclude_dir.length > 0 ? ('/!(' + exclude_dir.join('|') + ')/') : '/'
const excludeFiles = exclude_file && exclude_file.length > 0 ? ('!(' + exclude_file.join('|') + ')') : '*'
const glob = [`./${srcDir}${excludeDirs}**/${excludeFiles}.md`, `./${srcDir}${excludeDirs2}**/${excludeFiles}.md`, `./${srcDir}/${excludeFiles}.md`]
// console.log(srcDir, exclude_file, exclude_dir, glob)
export default createContentLoader(glob, {

@brc-dd
Copy link
Member

brc-dd commented Sep 19, 2023

It will be there in the next version. createContentLoader(..., { globOptions: {...} })

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants