(category: BlogCategory)
| 17 | }; |
| 18 | |
| 19 | export const getBlogPosts = (category: BlogCategory): BlogPostsRSC => { |
| 20 | const categoryPosts = blogData.posts.filter(post => |
| 21 | post.categories.includes(category) |
| 22 | ); |
| 23 | |
| 24 | // Total amount of possible pages given the amount of blog posts |
| 25 | const total = categoryPosts.length / BLOG_POSTS_PER_PAGE; |
| 26 | |
| 27 | return { |
| 28 | posts: categoryPosts, |
| 29 | pagination: { |
| 30 | prev: null, |
| 31 | next: null, |
| 32 | // In case the division results on a remainder we need |
| 33 | // to have an extra page containing the remainder entries |
| 34 | pages: Math.ceil(total), |
| 35 | total: categoryPosts.length, |
| 36 | }, |
| 37 | }; |
| 38 | }; |
| 39 | |
| 40 | export const paginateBlogPosts = ( |
| 41 | { posts, pagination }: BlogPostsRSC, |
no outgoing calls
no test coverage detected