Firstly, my absolute deepest apologies if this is not a nuxt/content related issue, I am trying to rule options out.
I've had this issue for a while now:
If you navigate directly to https://jackdomleo.dev/blog, it works fine. 馃憣 This will redirect to https://jackdomleo.dev/blog/.
If you navigate to https://jackdomleo.dev then click the 'Blog' nav item, no content is shown with no warnings/errors.
I have noticed the content only shows if there is a trailing slash but won't show if there isn't a trailing slash.
nuxt/content version: 1.3.2
Hosting: GitHub Pages
Repo: https://github.com/JDomleo/jackdomleo.dev
File for the /blog page: https://github.com/JDomleo/jackdomleo.dev/blob/master/pages/blog/index.vue
Thank you in advance!!
Hi @JDomleo
Actually since fetch is asynchronous, mounted is called before fetch on client-side navigation. Making filteredArticles empty since this.articles is still [].
Two solutions:
computed property for filteredArticles (I recommend)filterArticles in fetch:`js
async fetch () {
this.articles = await this.$content('blog', { deep: true }).only(['title', 'date', 'slug', 'description', 'readingTime', 'hashtags']).sortBy('date', 'desc').fetch();
this.filterArticles()
}
Thank you @Atinux, this is excellent help!!
Most helpful comment
Hi @JDomleo
Actually since
fetchis asynchronous,mountedis called beforefetchon client-side navigation. MakingfilteredArticlesempty sincethis.articlesis still[].Two solutions:
computedproperty forfilteredArticles(I recommend)filterArticlesinfetch:`
js async fetch () { this.articles = await this.$content('blog', { deep: true }).only(['title', 'date', 'slug', 'description', 'readingTime', 'hashtags']).sortBy('date', 'desc').fetch(); this.filterArticles() }