How to fetch from all child folders?
See original GitHub issueI have this directory structure:
- content/
- articles/
- 2020/
- 2019/
- 2018/
- projects/
I want to be able to fetch every .md
file from the content/articles/
directory.
I have tried the following:
this.articles = await this.$content('articles/**/*').fetch();
this.articles = await this.$content('articles/*').fetch();
this.articles = await this.$content('articles/').fetch();
this.articles = await this.$content('articles').fetch();
Any ideas how I can achieve this?
Extra info:
My first step was to place all articles inside the articles
directory and fetch them from there, and it worked perfectly. I’m now looking to further split my articles into year directories.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Run git pull over all subdirectories [duplicate] - Stack Overflow
Run the following from the parent directory, plugins in this case: find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} ...
Read more >How do you git fetch all repos in a folder? - Ask Different
One can combine find . -type d -iname ".git" -exec echo {} \; and replace echo command with a script with the following...
Read more >How to Retrieve Files from All Subfolders in Windows File ...
Get more tips for the awesome analyst at georgejmount.com.In this video we will look at how to retrieve files across subfolders with a...
Read more >PowerTip: List all subfolders under a target path with PowerShell
Here's an example that targets drive c: and all hidden folders. It displays only directories and their full paths. Get-ChildItem -Path C ...
Read more >Shell script to run `git pull` inside all subdirectories which are ...
Shell script to run `git pull` inside all subdirectories which are git repositories. I keep a number of projects in a folder &...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found a solution that was nearly what I wanted but I’m happy with it.
nuxt.config.js
@/pages/blog/_slug.vue
This solution allows me to keep the markdown files inside separate directories for their year, but the year is no longer in the URL.
E.g.
@/content/blog/2020/example-1.md
would appear at URLhttp://domain.com/blog/example-1
and I’m absolutely ok with that. Seems like the most logical solution. Thanks for your help @TheLearneer!@JDomleo
Also even if you do not are not planning to create a dedicated page for year itself, seems like you are still going for
year/article
format, so you will have to be careful there…@jbnv Make sure your content module is updated to at least 1.3.0 because that is when the deep fetch was introduced… Also seems like you are trying to fetch the root content directory. I stronly suggest you to put your files in some sub directory because even if doesn’t make any sense now, you will realize later than doing so will be useful in many ways… That is because if you plan to add some other type of content in future then your code will throw error for sure and also fetching content from specific folder would be more safer.