-
Notifications
You must be signed in to change notification settings - Fork 12
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 fetching all files and/or with filename pattern matching to use as documents #37
Comments
Hey, I totally understand your use-case, and it makes sense, but I don't really know how to implement this in a way that works nicely and easily. The problem is that the plugin is currently designed to work on almost any platform or provider, meaning that GitHub is supported just as well as GitLab, and so on so forth. Where are you fetching your content from? Based on that, you can likely use the documents parameter to pass an async function that fetches the names of all the things needing to be downloaded. I can see why this would be helpful, I just don't want to implement something without making sure it works for most users, won't break, etc. |
So in this case, the content would be pulled from other Github repositories. The reason for this is that we want to keep clean and distinct repositories that each serve a purpose, have their own contribution permissioning, and branch protection. |
That makes sense. I think that for your use-case, you can just use Octokit with the GitHub trees API to make a list of all the files, then filter it down to the ones you want, and return it from the documents parameter as a function. It requires a bit of scripting but ultimately it will very likely work. |
I would also love to have this feature. How can I fetch all markdown files? I dont want to have to define every markdown file to fetch every time someone adds a new markdown file in a remote repo. |
I can see that this use case is one that multiple people want to see as official functionality, so I will add it to my to-do list. |
yeah @RDIL, I got the support for that ready. Will share the code soon, so that you can integrate back into your plugin – as you like. |
@sw-tracker, @galligan I published the code under https://github.com/1amcode/docusaurus-lib-list-remote |
@1amcode studying for final exams this week, so I can't write any code for a bit, but I think the best way to do it would to be integrating it as a GitHub "provider" in the plugin, probably with some shorthand config syntax to active it. This would allow for future providers for other platforms to be added, which I believe is important. Hopefully I can start working on this next week though. |
This function can be used for this purpose, pass the author, repo, branch parameters.
This function then returns a configuration array -
The function -
You will have to write your docusauras config as a async function, invoke this script first and use the config returned by it.
|
Problem
I have a desire to populate a Docusaurus instance with content from multiple distinct repos. The content in those “remote” (relative to the Docusaurus instance) may change, and therefore can’t be explicitly defined.
Proposed solution
It would be hugely beneficial if I could simply say “all” files within a repo are downloaded, or if I could use filename pattern matching to filter a subset of documents to download.
In practice, perhaps this means that within
documents
I could pass a non-area string such as:all
: this would fetch all files in a given directoryfaq*
: this would fetch all files that begin withfaq
Other thoughts
What I’m not clear on is whether or not it would be useful to define specifics around subcategories. Perhaps this would mean that for a given directory, I could look for all files that begin with
faq
, traversing subdirectories, ignoring the files that don’t begin withfaq
, and then downloading the results, preserving the subdirectory structure along the way.Thanks for your consideration!
The text was updated successfully, but these errors were encountered: