MCPcopy Create free account
hub / github.com/nodejs/nodejs.org / getBlogPosts

Function getBlogPosts

apps/site/util/blog.ts:19–38  ·  view source on GitHub ↗
(category: BlogCategory)

Source from the content-addressed store, hash-verified

17};
18
19export 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
40export const paginateBlogPosts = (
41 { posts, pagination }: BlogPostsRSC,

Callers 3

getFeedsFunction · 0.90
getBlogDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected