From 86f47722667d818ddf6ab729b4f71c2f26228637 Mon Sep 17 00:00:00 2001 From: Arthur DANJOU Date: Thu, 17 Dec 2020 19:39:27 +0100 Subject: [PATCH] working --- .../en/new-version-new-website.md | 0 .../fr/new-version-new-website.md | 0 pages/blog/_slug.vue | 2 +- pages/blog/index.vue | 20 +++++++++++-------- 4 files changed, 13 insertions(+), 9 deletions(-) rename content/{ => articles}/en/new-version-new-website.md (100%) rename content/{ => articles}/fr/new-version-new-website.md (100%) diff --git a/content/en/new-version-new-website.md b/content/articles/en/new-version-new-website.md similarity index 100% rename from content/en/new-version-new-website.md rename to content/articles/en/new-version-new-website.md diff --git a/content/fr/new-version-new-website.md b/content/articles/fr/new-version-new-website.md similarity index 100% rename from content/fr/new-version-new-website.md rename to content/articles/fr/new-version-new-website.md diff --git a/pages/blog/_slug.vue b/pages/blog/_slug.vue index 3d38e6d..c89e5a2 100644 --- a/pages/blog/_slug.vue +++ b/pages/blog/_slug.vue @@ -121,7 +121,7 @@ export default { } }, async asyncData({ params, $content, app, $axios, error }) { - const post = await $content(`${app.i18n.locale}`, params.slug) + const post = await $content(`articles/${app.i18n.locale}`, params.slug) .fetch() .catch(() => { error({ statusCode: 404, message: "Post not found" }); diff --git a/pages/blog/index.vue b/pages/blog/index.vue index 5fc8133..c8c2756 100644 --- a/pages/blog/index.vue +++ b/pages/blog/index.vue @@ -132,7 +132,7 @@ export default { }, async resetPosts() { this.current_tag = '' - this.posts = await this.$content(`${this.$i18n.locale}`) + this.posts = await this.$content(`articles/${this.$i18n.locale}`) .sortBy('date', 'asc') .limit(5) .fetch() @@ -159,13 +159,13 @@ export default { async fetchPosts() { let postsTemp = [] if (this.current_tag === "") { - postsTemp = await this.$content(`${this.$i18n.locale}`) + postsTemp = await this.$content(`articles/${this.$i18n.locale}`) .sortBy('date', 'asc') .limit(5) .skip(this.page * 5) .fetch() } else { - postsTemp = await this.$content(`${this.$i18n.locale}`) + postsTemp = await this.$content(`articles/${this.$i18n.locale}`) .sortBy('date', 'asc') .limit(5) .skip(this.page * 5) @@ -184,13 +184,13 @@ export default { this.posts = posts }, async fetchPrevAndNext() { - const [_, next] = await this.$content(`${this.$i18n.locale}`) + const [_, next] = await this.$content(`articles/${this.$i18n.locale}`) .surround(this.posts[this.posts.length - 1].slug, { before: 1, after: 1 }) .fetch() - const [prev, __] = await this.$content(`${this.$i18n.locale}`) + const [prev, __] = await this.$content(`articles/${this.$i18n.locale}`) .skip(this.page) .surround(this.posts[0].slug, { before: 1, @@ -210,7 +210,10 @@ export default { }, async asyncData ({ $content, app }) { const tags = await $content('tags').fetch() - const postsTemp = await $content(`${app.i18n.locale}`) + + const locale = await app.i18n.locale + + const postsTemp = await $content(`articles/${locale}`) .sortBy('date', 'asc') .limit(5) .fetch() @@ -219,19 +222,20 @@ export default { postsTemp.map(post => { posts.push(post) }) + console.log(posts) let prev = null let next = null if (posts.length > 0) { - const [_, nextTemp] = await $content(`${app.i18n.locale}`) + const [_, nextTemp] = await $content(`articles/${locale}`) .surround(posts[posts.length - 1].slug, { before: 1, after: 1 }) .fetch() - const [prevTemp, __] = await $content(`${app.i18n.locale}`) + const [prevTemp, __] = await $content(`articles/${locale}`) .surround(posts[0].slug, { before: 1, after: 1