Skip to content

Commit

Permalink
better tags generating method in index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
medmin committed Nov 22, 2019
1 parent 65a9006 commit ae31465
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
};

Expand Down

0 comments on commit ae31465

Please sign in to comment.