Skip to content

Commit

Permalink
refactor: tagの投稿リスト生成をmap関数を使用して簡素化
Browse files Browse the repository at this point in the history
  • Loading branch information
hiro0218 committed Nov 1, 2024
1 parent 05120d1 commit 32fa01e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/pages/tags/[slug]/_libs/getStaticPropsTagDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ const allTags = getTagsJson();
export const getStaticPropsTagDetail: GetStaticProps<TermProps> = (context: GetStaticPropsContext) => {
const slug = context.params?.slug as string;
const tag = allTags[slug];
const tagsPosts: TermsPostListProps[] = [];

for (const postSlug of tag) {
const tagsPosts: TermsPostListProps[] = tag.map((postSlug: string) => {
const { title, date, updated } = allPosts.get(postSlug);
tagsPosts.push({
return {
title,
slug: postSlug,
date,
...(updated && { updated }),
});
}
};
});

return {
props: {
Expand Down

0 comments on commit 32fa01e

Please sign in to comment.