Skip to content

Commit

Permalink
refactor: popularPostsSlugsのソート処理を関数外に移動
Browse files Browse the repository at this point in the history
  • Loading branch information
hiro0218 committed Nov 1, 2024
1 parent d65a5e2 commit 05120d1
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/pages/_libs/getPopularPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import { type getPostsListJson, getPostsPopular } from '@/lib/posts';
import { IGNORE_SLUGS } from './constant';

const popularPostsSlugs = getPostsPopular();
/** popularPostsSlugsを配列に変換し、数値が多い順にソート */
const sortedSlugs = Object.entries(popularPostsSlugs).map(([slug]) => slug);

export const getPopularPost = (posts: ReturnType<typeof getPostsListJson>, displayLimit: number) => {
// popularPostsSlugsを配列に変換し、数値が多い順にソート
const sortedSlugs = Object.entries(popularPostsSlugs).map(([slug]) => slug);

const popularPosts = sortedSlugs
.filter((slug) => !IGNORE_SLUGS.has(slug))
.map((slug) => {
Expand Down

0 comments on commit 05120d1

Please sign in to comment.