From 6ae63f10403fa5f5cbe5d9d10a40b2ab767dca48 Mon Sep 17 00:00:00 2001 From: PigeonsHouse Date: Tue, 28 Nov 2023 23:10:34 +0900 Subject: [PATCH] =?UTF-8?q?update:=20TOP=E3=83=9A=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=81=AEToyboxBlog=E3=81=B8=E3=81=AE=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/top/TopBlog.vue | 2 +- pages/index.vue | 81 ++++++++++++++++++++++---------------- 2 files changed, 49 insertions(+), 34 deletions(-) diff --git a/components/top/TopBlog.vue b/components/top/TopBlog.vue index 0e70e41..3a5b13f 100644 --- a/components/top/TopBlog.vue +++ b/components/top/TopBlog.vue @@ -5,7 +5,7 @@ { - const communities = [] - const selectNews = [] - for (let i = 0; i < eachCommunity.items.length; i++) { - communities.push({ - id: eachCommunity.items[i].sys.id, - field: { - name: eachCommunity.items[i].fields.name, - domain: eachCommunity.items[i].fields.domain, - image: eachCommunity.items[i].fields.image.fields.file.url, - simage: eachCommunity.items[i].fields.smallimg.fields.file.url, - }, - }) - } - for (let i = 0; i < news.items.length; i++) { - if (news.items[i].fields.important) { - selectNews.push(news.items[i]) + await axios.get(`${process.env.TOYBOX_API_BASE_URL}/blogs?limit=5`), + ]).then( + ([ + c3Introduction, + eachCommunity, + news, + blog, + toyboxWork, + toyboxblog, + ]) => { + const communities = [] + const selectNews = [] + for (let i = 0; i < eachCommunity.items.length; i++) { + communities.push({ + id: eachCommunity.items[i].sys.id, + field: { + name: eachCommunity.items[i].fields.name, + domain: eachCommunity.items[i].fields.domain, + image: eachCommunity.items[i].fields.image.fields.file.url, + simage: eachCommunity.items[i].fields.smallimg.fields.file.url, + }, + }) } - } - const latestNews = news.items.slice(0, 5) + for (let i = 0; i < news.items.length; i++) { + if (news.items[i].fields.important) { + selectNews.push(news.items[i]) + } + } + const latestNews = news.items.slice(0, 5) + + const works = toyboxWork.data.works.map((work) => { + return { + id: work.id, + title: work.title, + thumbnail: work.thumbnail.url, + } + }) - const works = toyboxWork.data.works.map((work) => { return { - id: work.id, - title: work.title, - thumbnail: work.thumbnail.url, + c3Introduction: + c3Introduction.items[0].fields.summaryOfIntroduction, + eachCommunity: communities, + news: latestNews, + importantNews: selectNews, + blog: toyboxblog.data.blogs + .map(formatToybox) + .concat(blog.items) + .slice(0, 5), + works, } - }) - - return { - c3Introduction: c3Introduction.items[0].fields.summaryOfIntroduction, - eachCommunity: communities, - news: latestNews, - importantNews: selectNews, - blog: blog.items, - works, } - }) + ) } catch (e) { error({ errorCode: e.errorCode,