-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
RFC: Pass subdirectory as an argument to injectContentFiles
#347
Comments
You cannot define glob paths dynamically at runtime. So it would have to be a filter. It's a reasonable change though. You can filter the array of returned files also const posts = injectContentFiles().filter(someFilter) I think passing a callback function for a filter would work and be flexible enough to use in different ways |
Sounds good to me. I think the signature of the filter method can be passed as a predicate function. I will prepare a PR for this. |
this feature add a functionality to the injectContentFiles function to filter out some of the content files before it returns analogjs#347
this feature add a functionality to the injectContentFiles function to filter out some of the content files before it returns analogjs#347
The related PR is here: |
Which scope/s are relevant/related to the feature request?
content
Information
Currently, when we run the
injectContentFiles
function, we collect all the available files from thecontent
folder.I would like to suggest a way, that only the files from the specified subdirectory are returned.
Proposed API change:
function injectContentFiles<Attributes extends Record<string, any>>(options?: { subdirectory?: string }): ContentFile<Attributes>[]
As I see the current implementation comes with the
InjectionToken
factory. We cannot pass an argument to the factory function so some workaround needs to be done here. One possible solution is to have a service that stores thesubdirectory
value, and we use theinject
function to access this service when we call thegetContentFilesList
function.We can change this file to accept a subdirectory value like this:
Describe any alternatives/workarounds you're currently using
Currently I think the only workaround is to get all the files, and filter the array for the specific folder files.
I would be willing to submit a PR to fix this issue
The text was updated successfully, but these errors were encountered: