File tree Expand file tree Collapse file tree
apps/site/next-data/providers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,17 +4,18 @@ import { BLOG_POSTS_PER_PAGE } from '@/next.constants.mjs';
44import { blogData } from '@/next.json.mjs' ;
55import type { BlogCategory , BlogPostsRSC } from '@/types' ;
66
7- const { categories } = blogData ;
8- const posts = blogData . posts . map ( post => ( {
9- ...post ,
10- date : new Date ( post . date ) ,
11- } ) ) ;
7+ function getPosts ( ) {
8+ return blogData . posts . map ( post => ( {
9+ ...post ,
10+ date : new Date ( post . date ) ,
11+ } ) ) ;
12+ }
1213
13- export const provideBlogCategories = cache ( ( ) => categories ) ;
14+ export const provideBlogCategories = cache ( ( ) => blogData . categories ) ;
1415
1516export const provideBlogPosts = cache (
1617 ( category : BlogCategory ) : BlogPostsRSC => {
17- const categoryPosts = posts
18+ const categoryPosts = getPosts ( )
1819 . filter ( post => post . categories . includes ( category ) )
1920 . sort ( ( a , b ) => b . date . getTime ( ) - a . date . getTime ( ) ) ;
2021
You can’t perform that action at this time.
0 commit comments