11import { pathOr , union } from 'ramda'
22
3- export const getAllPostData = ( state ) =>
3+ export const getAllPostsData = ( state ) =>
44 pathOr ( { } , [ 'data' , 'posts' ] , state )
55
66export const getPostData = ( state , post ) =>
@@ -36,21 +36,21 @@ export const getAllPostDetails = (state, post) => ({
3636} )
3737
3838export const getAllPostsForListing = ( state ) => Object
39- . keys ( getAllPostData ( state ) )
39+ . keys ( getAllPostsData ( state ) )
4040 . map ( post => ( { ...getAllPostDetails ( state , post ) } ) )
4141
4242export const getAllPostsTags = ( state ) => {
4343 let tags = [ ]
4444 Object
45- . keys ( getAllPostData ( state ) )
45+ . keys ( getAllPostsData ( state ) )
4646 . forEach ( post => tags = union ( tags , getPostTags ( state , post ) ) )
4747 return tags
4848}
4949
5050export const getAllPostsCategories = ( state ) => {
5151 let categories = [ ]
5252 Object
53- . keys ( getAllPostData ( state ) )
53+ . keys ( getAllPostsData ( state ) )
5454 . forEach ( post => categories = union ( categories , [ getPostCategory ( state , post ) ] ) )
5555 return categories
5656}
@@ -75,6 +75,9 @@ export const getAllArticleDetails = (state, article) => ({
7575 files : getArticleData ( state , article ) ,
7676} )
7777
78+ export const getAllCategoriesData = ( state ) =>
79+ pathOr ( { } , [ 'data' , 'categories' ] , state )
80+
7881export const getCategoryData = ( state , category ) =>
7982 pathOr ( { } , [ 'data' , 'categories' , category ] , state )
8083
@@ -95,7 +98,11 @@ export const getAllCategoryDetails = (state, category) => ({
9598 files : getCategoryData ( state , category ) ,
9699} )
97100
101+ export const getAllCategoriesForListing = ( state ) => Object
102+ . keys ( getAllCategoriesData ( state ) )
103+ . map ( category => ( { ...getAllCategoryDetails ( state , category ) } ) )
104+
98105export const getAllPostsForListingByCategory = ( state , category ) => Object
99- . keys ( getAllPostData ( state ) )
106+ . keys ( getAllPostsData ( state ) )
100107 . filter ( post => category === getPostCategory ( state , post ) )
101108 . map ( post => ( { ...getAllPostDetails ( state , post ) } ) )
0 commit comments