@@ -13,21 +13,36 @@ import { FALLBACK, handleRedirectsAndReturnData } from '../../src/utils/slug';
13
13
import { sanitize } from '../../src/utils/miscellaneous' ;
14
14
import { HEADER_FOOTER_ENDPOINT } from '../../src/utils/constants/endpoints' ;
15
15
import { getPost , getPosts } from '../../src/utils/blog' ;
16
+ import Image from '../../src/components/image' ;
17
+ import PostMeta from '../../src/components/post-meta' ;
16
18
17
19
const Post = ( { headerFooter, postData } ) => {
18
20
const router = useRouter ( ) ;
19
21
20
- console . log ( 'postData' , postData ) ;
21
-
22
- // If the page is not yet generated, this will be displayed
23
- // initially until getStaticProps() finishes running
22
+ /**
23
+ * If the page is not yet generated, this will be displayed
24
+ * initially until getStaticProps() finishes running
25
+ */
24
26
if ( router . isFallback ) {
25
27
return < div > Loading...</ div > ;
26
28
}
27
29
28
30
return (
29
31
< Layout headerFooter = { headerFooter || { } } seo = { null } >
30
- { /*<div dangerouslySetInnerHTML={ { __html: sanitize( data?.post?.content ?? {} ) } }/>*/ }
32
+ < div className = "mb-8 w-4/5 m-auto" >
33
+ < figure className = "overflow-hidden mb-4" >
34
+ < Image
35
+ sourceUrl = { postData ?. attachment_image ?. img_src ?. [ 0 ] ?? '' }
36
+ title = { postData ?. title ?? '' }
37
+ width = { postData ?. attachment_image ?. img_src ?. [ 1 ] ?? '600' }
38
+ height = { postData ?. attachment_image ?. img_src ?. [ 2 ] ?? '400' }
39
+ layout = "fill"
40
+ containerClassNames = "w-full h-600px"
41
+ />
42
+ </ figure >
43
+ < PostMeta post = { postData } />
44
+ < div dangerouslySetInnerHTML = { { __html : sanitize ( postData ?. content ?? '' ) } } />
45
+ </ div >
31
46
</ Layout >
32
47
) ;
33
48
} ;
@@ -37,11 +52,12 @@ export default Post;
37
52
export async function getStaticProps ( { params } ) {
38
53
const { data : headerFooterData } = await axios . get ( HEADER_FOOTER_ENDPOINT ) ;
39
54
const { data : postData } = await getPost ( params ?. slug ?? '' ) ;
55
+ // params?.slug ?? ''
40
56
41
57
const defaultProps = {
42
58
props : {
43
59
headerFooter : headerFooterData ?. data ?? { } ,
44
- postData : postData || { }
60
+ postData : postData ?. post_data ?? { }
45
61
} ,
46
62
/**
47
63
* Revalidate means that if a new request comes to server, then every 1 sec it will check
@@ -50,10 +66,8 @@ export async function getStaticProps( { params } ) {
50
66
*/
51
67
revalidate : 1 ,
52
68
} ;
53
-
54
- return defaultProps ;
55
69
56
- // return handleRedirectsAndReturnData( defaultProps, postData, 'post ' );
70
+ return handleRedirectsAndReturnData ( defaultProps , postData , 'post_data ' ) ;
57
71
}
58
72
59
73
/**
0 commit comments