Skip to content

Commit 66e2f13

Browse files
styling single page blog
1 parent fe137d5 commit 66e2f13

File tree

5 files changed

+93
-8
lines changed

5 files changed

+93
-8
lines changed

client/components/blog/Card/Card.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const Card =({blog})=>{
4343
</Link>
4444
</header>
4545
<section>
46-
<CategoryIcon style={{color:"limegreen"}}/>[{listAndDisplayAllCategories(blog)}]<LabelIcon style={{color:"teal"}}/>[{listAndDisplayAllTaglists(blog)}]
46+
<CategoryIcon style={{color:"limegreen"}}/>{listAndDisplayAllCategories(blog)} <LabelIcon style={{color:"teal"}}/>{listAndDisplayAllTaglists(blog)}
4747
</section>
4848
<div className="row">
4949
<div className="col-md-4">

client/pages/blogs/[slug].js

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,86 @@
11
import Head from 'next/head';
22
import Link from 'next/link';
3-
import {withRouter} from "next/router";
43
import Layout from '../../components/Layout';
54
import React,{ useState,useEffect } from 'react';
65
import { singleBlog } from '../../actions/blog';
76
import LabelIcon from '@material-ui/icons/Label';
87
import CategoryIcon from '@material-ui/icons/Category';
98
import {API,DOMAIN,APP_NAME} from '../../config';
109
import 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);

client/pages/blogs/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const Blogs = ({blogs,categories,taglists,totalBlogs,blogsLimit,blogSkip,router}
9797
<>
9898
{head()}
9999
<Layout>
100-
<main>
100+
<main className="blog-foreground">
101101
<div className="container-fluid">
102102
<header>
103103
<div className="col-md-12 pt-3">

client/static/assets/blackback.jpg

813 KB
Loading

client/static/styles/styles.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,30 @@ html {
2525
scrollbar-width: none;
2626
}
2727

28+
.blog-foreground {
29+
backdrop-filter: blur(7px);
30+
}
31+
2832
.ql-editor {
2933
min-height: 25rem;
3034
}
35+
36+
.background-image {
37+
width: 100%;
38+
max-height: 400px;
39+
object-fit: cover;
40+
}
41+
42+
.singleblog-background {
43+
background: url("../assets/blackback.jpg") no-repeat center center fixed;
44+
/* background: url("../assets/19390.jpg") no-repeat center center fixed; */
45+
/* background: url("../assets/blackback.jpg") no-repeat center center fixed; */
46+
-webkit-background-size: cover;
47+
-moz-background-size: cover;
48+
-o-background-size: cover;
49+
background-size: cover;
50+
}
51+
52+
.singleblog-foreground {
53+
backdrop-filter: blur(7px);
54+
}

0 commit comments

Comments
 (0)