Hello,
i want to fetch post for three differnet categroies at my home page , so what is best way to do it,
my design looks like below ,
if you want to show the posts ordered by date, you have to modify the helper:
...
export const getPostsGroupedByCategory = state => {
return Object.keys(state.theme.menuCategories).reduce((acc, categoryId) => {
const posts = getPostsFromCategory(state.source, categoryId)
.sort((a, b) => a.date < b.date ? 1 : -1)
.slice(0, 4)
const category = state.source.category[categoryId]
return [{ posts, category }, ...acc]
}, [])
}
...