11import Head from 'next/head' ;
22import Link from 'next/link' ;
3- import { withRouter } from "next/router" ;
43import Layout from '../../components/Layout' ;
54import React , { useState , useEffect } from 'react' ;
65import { singleBlog } from '../../actions/blog' ;
76import LabelIcon from '@material-ui/icons/Label' ;
87import CategoryIcon from '@material-ui/icons/Category' ;
98import { API , DOMAIN , APP_NAME } from '../../config' ;
109import ExpandMoreIcon from '@material-ui/icons/ExpandMore' ;
10+ import moment from 'moment' ;
11+ import renderHTML from 'react-render-html' ;
1112
1213
13- const SingleBlog = ( { blog, router} ) => {
14+
15+
16+ const SingleBlog = ( { blog} ) => {
17+
18+ const listAndDisplayAllCategories = blog => {
19+ return (
20+ blog . categories . map ( ( cat , index ) => {
21+ return (
22+ < Link key = { index } href = { `/categories/${ cat . slug } ` } >
23+ < a className = "btn btn-sm btn-outline-success mr-1 ml-1 mt-3 mb-4" > { cat . name } </ a >
24+ </ Link >
25+ )
26+ } )
27+ )
28+ } ;
29+
30+ const listAndDisplayAllTaglists = blog => {
31+ return (
32+ blog . taglists . map ( ( tagg , index ) => {
33+ return (
34+ < Link key = { index } href = { `/taglists/${ tagg . slug } ` } >
35+ < a className = "btn btn-sm btn-outline-info mr-1 ml-1 mt-3 mb-4" > { tagg . name } </ a >
36+ </ Link >
37+ )
38+ } )
39+ )
40+ } ;
41+
1442 return (
1543 < >
1644 < Layout >
17- < main >
18- < article >
45+ < main className = "singleblog-background" >
46+ < article className = "singleblog-foreground" >
1947 < div className = "container-fluid" >
2048 < section >
21- { JSON . stringify ( blog ) }
49+ < div className = "row" style = { { marginTop :"0px" } } >
50+ < img src = { `${ API } /api/blog/photo/${ blog . slug } ` } alt = { blog . title } className = "img img-fluid background-image" />
51+ </ div >
2252 </ section >
53+ < section >
54+ < p className = "lead pb-1 pt-1" >
55+ < div style = { { backgroundColor :"inset 0 0 2000px rgba(255, 255, 255, .5)" , filter :"blur(0.7px)" , fontSize :"15px" } } > Author : { blog . postedBy . name } | Published { moment ( blog . updatedAt ) . fromNow ( ) } </ div >
56+ </ p >
57+ < div className = "pb-3" >
58+ < CategoryIcon style = { { color :"limegreen" } } /> { listAndDisplayAllCategories ( blog ) } < LabelIcon style = { { color :"teal" } } /> { listAndDisplayAllTaglists ( blog ) }
59+ </ div >
60+ </ section >
61+ < section >
62+ < div className = "text-center" >
63+ < h3 className = "pt-4 pb-3" style = { { backgroundColor :"inset 0 0 2000px rgba(255, 255, 255, 1)" , filter :"blur(0.5px)" , color :"#ff4500" , fontSize :"40px" , fontWeight :"bold" } } > { blog . title } </ h3 >
64+ </ div >
65+ </ section >
66+ </ div >
67+ < div className = "container" >
68+ < section >
69+ < div className = "col-md-12 lead" style = { { textAlign :"justify" } } > { renderHTML ( blog . body ) } </ div >
70+ </ section >
71+ </ div >
72+
73+ { /* // Related blogs */ }
74+ < div className = "container pb-5" >
75+ < h4 className = "text-center pb-5 pt-5 h2" > Related Blogs</ h4 >
76+ < hr />
77+ < p > Show Related Blogs</ p >
78+ </ div >
79+
80+ { /* Disqus commneting */ }
81+ < div className = "container pb-5" >
82+ < hr />
83+ < p > Disqus Comments</ p >
2384 </ div >
2485 </ article >
2586 </ main >
@@ -38,4 +99,4 @@ SingleBlog.getInitialProps=({query})=>{
3899 } )
39100}
40101
41- export default withRouter ( SingleBlog ) ;
102+ export default ( SingleBlog ) ;
0 commit comments