Skip to content

Commit 101cac1

Browse files
define blogPosts as suggested
1 parent 23ff871 commit 101cac1

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

apps/site/next-data/providers/blogData.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ import { BLOG_POSTS_PER_PAGE } from '@/next.constants.mjs';
44
import { blogData } from '@/next.json.mjs';
55
import type { BlogCategory, BlogPostsRSC } from '@/types';
66

7-
function getPosts() {
8-
return blogData.posts.map(post => ({
7+
const blogPosts = cache(() =>
8+
blogData.posts.map(post => ({
99
...post,
1010
date: new Date(post.date),
11-
}));
12-
}
13-
14-
const posts = getPosts();
11+
}))
12+
);
1513

1614
export const provideBlogPosts = cache(
1715
(category: BlogCategory): BlogPostsRSC => {
18-
const categoryPosts = posts
16+
const categoryPosts = blogPosts()
1917
.filter(post => post.categories.includes(category))
2018
.sort((a, b) => b.date.getTime() - a.date.getTime());
2119

0 commit comments

Comments
 (0)