File tree 5 files changed +92
-9
lines changed
5 files changed +92
-9
lines changed Original file line number Diff line number Diff line change 1
- import Layout from '../../src/components/layout' ;
2
- // import { PER_PAGE_FIRST, totalPagesCount } from '../../src/utils/pagination';
3
- // import Pagination from '../../src/components/blog/pagination';
4
- // import Posts from '../../src/components/blog/posts';
1
+ /**
2
+ * External Dependencies.
3
+ */
5
4
import axios from 'axios' ;
6
- import { GET_POSTS_ENDPOINT , HEADER_FOOTER_ENDPOINT } from '../../src/utils/constants/endpoints' ;
5
+
6
+ /**
7
+ * Internal Dependencies.
8
+ */
9
+ import Layout from '../../src/components/layout' ;
10
+ import { HEADER_FOOTER_ENDPOINT } from '../../src/utils/constants/endpoints' ;
7
11
import { getPosts } from '../../src/utils/blog' ;
12
+ import Posts from '../../src/components/posts' ;
8
13
9
- const Blog = ( { headerFooter } ) => {
10
- // const pagesCount = totalPagesCount( data?.posts?.pageInfo?.offsetPagination?.total ?? 0 );
14
+ const Blog = ( { headerFooter, postsData } ) => {
15
+ console . log ( 'postsData' , postsData ) ;
11
16
return (
12
17
< Layout headerFooter = { headerFooter || { } } seo = { null } >
13
- { /*<Posts posts={data?.posts?.edges ?? []}/>*/ }
14
- { /*<Pagination pagesCount={pagesCount} postName="blog" />*/ }
18
+ < h1 > Blog</ h1 >
19
+ < Posts posts = { postsData ?. posts_data ?? [ ] } />
20
+ { /*<Pagination pagesCount={postsData?.page_count} postName="blog" />*/ }
15
21
</ Layout >
16
22
) ;
17
23
} ;
Original file line number Diff line number Diff line change @@ -52,6 +52,9 @@ const Header = ( { header } ) => {
52
52
dangerouslySetInnerHTML = { { __html : menuItem . title } } />
53
53
</ Link >
54
54
) ) : null }
55
+ < Link href = "/blog" >
56
+ < a className = "block mt-4 lg:inline-block lg:mt-0 hover:text-brand-royal-blue duration-500 mr-10" > Blog</ a >
57
+ </ Link >
55
58
</ div >
56
59
< div className = "text-sm font-medium" >
57
60
< a href = "#responsive-header"
Original file line number Diff line number Diff line change
1
+ /**
2
+ * External Dependencies.
3
+ */
4
+ import PropTypes from 'prop-types' ;
5
+ import { isEmpty , isArray } from 'lodash' ;
6
+
7
+ /**
8
+ * Internal Dependency.
9
+ */
10
+ import Post from './post' ;
11
+
12
+
13
+ const Posts = ( { posts } ) => {
14
+
15
+ if ( isEmpty ( posts ) && ! isArray ( posts ) ) {
16
+ return null ;
17
+ }
18
+
19
+ return (
20
+ < div className = "flex flex-wrap -mb-4" >
21
+ {
22
+ posts . map ( ( post , index ) => {
23
+ return (
24
+ < div
25
+ key = { `${ post ?. id ?? '' } -${ index } ` ?? '' }
26
+ className = "w-full md:w-1/2 lg:w-1/3 mb-4 px-2"
27
+ >
28
+ < Post post = { post } />
29
+ </ div >
30
+ ) ;
31
+ } )
32
+ }
33
+ </ div >
34
+ ) ;
35
+ } ;
36
+
37
+ Posts . propTypes = {
38
+ posts : PropTypes . array ,
39
+ } ;
40
+
41
+ Posts . defaultProps = {
42
+ posts : [ ] ,
43
+ } ;
44
+
45
+ export default Posts ;
Original file line number Diff line number Diff line change
1
+ import Link from 'next/link' ;
2
+ import Image from '../image' ;
3
+ import { sanitize } from '../../utils/miscellaneous' ;
4
+
5
+ const Post = ( { post} ) => {
6
+
7
+ return (
8
+ < div className = "mb-8" >
9
+ < figure className = "overflow-hidden mb-4" >
10
+ < Image
11
+ sourceUrl = { post ?. attachment_image ?. img_src ?? '' }
12
+ title = { post ?. title ?? '' }
13
+ width = "400"
14
+ height = "225"
15
+ layout = "fill"
16
+ containerClassNames = "w-96 sm:-w-600px md:w-400px h-56 sm:h-338px md:h-225px"
17
+ />
18
+ </ figure >
19
+ < Link href = { `/blog/${ post ?. slug } /` } >
20
+ < a >
21
+ < h2 className = "font-bold mb-3 text-lg hover:text-blue-500" dangerouslySetInnerHTML = { { __html : sanitize ( post ?. title ?? '' ) } } />
22
+ </ a >
23
+ </ Link >
24
+ < div dangerouslySetInnerHTML = { { __html : sanitize ( post ?. excerpt ?? '' ) } } />
25
+ </ div >
26
+ ) ;
27
+ } ;
28
+
29
+ export default Post ;
You can’t perform that action at this time.
0 commit comments