From ae31465a8bdac405c82cae4513423f65ebe48d7f Mon Sep 17 00:00:00 2001 From: medmin Date: Fri, 22 Nov 2019 11:17:17 -0800 Subject: [PATCH] better tags generating method in index.js --- pages/index.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pages/index.js b/pages/index.js index 7f4c6ad..3373c64 100644 --- a/pages/index.js +++ b/pages/index.js @@ -44,14 +44,9 @@ IndexPage.getInitialProps = async () => { let all = respPosts.status == 200 ? [...respPosts.data] : []; let pinned = respStickyPosts.status == 200 ? [...respStickyPosts.data] : []; - let tags = {}; const tagsOK = respTags.status == 200; - // console.log(Object.values(respTags.data)); - if (tagsOK) { - for (let tag of respTags.data) { - tags[tag.id] = tag.slug; - } - } + const tags = tagsOK ? Object.fromEntries(respTags.data.map((tag) => [tag.id, tag.slug])) : {}; + return { all, pinned, tags }; };