This repository was archived by the owner on Feb 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +30
-2
lines changed Expand file tree Collapse file tree 1 file changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,33 @@ const postType = 'post'
14
14
* @param {Object } [props] Properties passed to the component.
15
15
* @return {Element } Element to render.
16
16
*/
17
- export default function BlogPost ( { post} ) {
17
+ export default function BlogPost ( { post, posts, archive} ) {
18
+ // Check for post archive.
19
+ // TODO create generic archive component and move this check to `_app.js`.
20
+ if ( archive ) {
21
+ return (
22
+ < Layout title = "Blog" >
23
+ < div className = "container" >
24
+ < section >
25
+ { ! posts || ! posts . length ? (
26
+ < p > No posts found.</ p >
27
+ ) : (
28
+ posts . map ( ( post , index ) => (
29
+ < >
30
+ < article key = { index } >
31
+ < h1 dangerouslySetInnerHTML = { { __html : post ?. title } } />
32
+ < div dangerouslySetInnerHTML = { { __html : post ?. excerpt } } />
33
+ </ article >
34
+ < hr />
35
+ </ >
36
+ ) )
37
+ ) }
38
+ </ section >
39
+ </ div >
40
+ </ Layout >
41
+ )
42
+ }
43
+
18
44
return (
19
45
< Layout title = { post ?. title } description = { post ?. excerpt } >
20
46
< div className = "container" >
@@ -64,5 +90,7 @@ export async function getStaticProps({params}) {
64
90
}
65
91
66
92
BlogPost . propTypes = {
67
- post : PropTypes . object
93
+ post : PropTypes . object ,
94
+ posts : PropTypes . array ,
95
+ archive : PropTypes . bool
68
96
}
You can’t perform that action at this time.
0 commit comments