Skip to content

Commit ae31465

Browse files
committed
better tags generating method in index.js
1 parent 65a9006 commit ae31465

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

pages/index.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,9 @@ IndexPage.getInitialProps = async () => {
4444
let all = respPosts.status == 200 ? [...respPosts.data] : [];
4545
let pinned = respStickyPosts.status == 200 ? [...respStickyPosts.data] : [];
4646

47-
let tags = {};
4847
const tagsOK = respTags.status == 200;
49-
// console.log(Object.values(respTags.data));
50-
if (tagsOK) {
51-
for (let tag of respTags.data) {
52-
tags[tag.id] = tag.slug;
53-
}
54-
}
48+
const tags = tagsOK ? Object.fromEntries(respTags.data.map((tag) => [tag.id, tag.slug])) : {};
49+
5550
return { all, pinned, tags };
5651
};
5752

0 commit comments

Comments
 (0)