queryContent(['/path1/', '/path2/']) - downloading data from different paths simultaneously
Is your feature request related to a problem? Please describe
I would like to download all articles, which unfortunately I have in two separate folders. To do this currently I have to download them individually and merge, or download everything from / and filter, which is not efficient.
In the documentation is written out the possibility of using something like this:
// Create a query looking into content/articles/nuxt3 directory
const contentQuery = queryContent('articles', 'nuxt3')
I don't think it would be useful, after all, you can use just
const contentQuery = queryContent('articles/nuxt3')
It would be better to turn this into an option to download from multiple paths simultaneously
Describe the solution you'd like
The solution I would like is to be able to insert an array in the queryContent:
const allArticles = queryContent(['/blog/', '/news/'])
Describe alternatives you've considered
const news = await queryContent('/news/').find()
const blog = await queryContent('/blog/').find()
const allArticles = news.concat(blog)
Additional context
You can simply download all files using / inside the queryContent, and then continuing in the same chain, you can use Content Module's where option to actually pick up only those two folders (blog, news).
This will be efficient compared to using normal JS filter.
You can use regex to fetch both directories:
const news = await queryContent().where({ _path: /^\/(news|blog)\// }).find()
You can use regex to fetch both directories:
const news = await queryContent().where({ _path: /^\/(news|blog)\// }).find()
Ok, and how could I sort the items the way I wanted with this? Because currently they behave "separately"
/news
1.test.md
3.article.md
/blog
2.blog-article.md
Now its:
test, article, blog-article
I want:
test, blog-article, article
@gitFoxCode Sort by slug, rather than path.
@gitFoxCode Sort by slug, rather than path.
Can also be sorted according to preference. Depending on various properties, such as categories or similar.