Skip to content

Commit ad880ab

Browse files
Lisiting and displaying all the categories and taglists inside blog page
1 parent 2f22611 commit ad880ab

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

client/components/blog/Card/Card.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import moment from 'moment';
55
import { API } from '../../../config';
66
import LabelIcon from '@material-ui/icons/Label';
77
import CategoryIcon from '@material-ui/icons/Category';
8+
import MoreHorizIcon from '@material-ui/icons/MoreHoriz';
9+
import MoreIcon from '@material-ui/icons/More';
10+
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
811

912
const Card =({blog})=>{
1013

@@ -33,10 +36,10 @@ const Card =({blog})=>{
3336
};
3437

3538
return (
36-
<div className="lead pb-4">
39+
<div className="lead pb-4" style={{boxShadow:"inset 0 0 2000px rgba(255, 255, 255, .5)",filter:"blur(0.1px)",borderRadius:"5px"}}>
3740
<header>
3841
<Link href={`/blogs/${blog.slug}`}>
39-
<a><h3 className="display-5 pt-3 pb-4 font-weight-bold">{blog.title}</h3></a>
42+
<a><h3 className="display-5 pt-4 pb-2 font-weight-bold pl-5">{blog.title}</h3></a>
4043
</Link>
4144
</header>
4245
<section>
@@ -52,7 +55,7 @@ const Card =({blog})=>{
5255
<section>
5356
<div className="pb-3">{renderHTML(blog.excerpt)}</div>
5457
<Link href={`/blogs/${blog.slug}`}>
55-
<a className="btn btn-info pt-2">Read more</a>
58+
<a className="btn btn-info pt-2">Read more <MoreIcon/></a>
5659
</Link>
5760
</section>
5861
</div>

client/pages/blogs/index.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,40 @@ import React,{ useState,useEffect } from 'react';
55
import { listBlogsWithCategoriesAndTaglists } from '../../actions/blog';
66
import { API } from '../../config';
77
import Card from "../../components/blog/Card";
8+
import LabelIcon from '@material-ui/icons/Label';
9+
import CategoryIcon from '@material-ui/icons/Category';
810

911

1012
const Blogs = ({blogs,categories,taglists,size}) => {
1113
const listAndDisplayAllBlogs = ()=>{
1214
return blogs.map((blog,index)=>(
1315
<article key={index}>
1416
<Card blog={blog}/>
15-
<hr style={{backgroundColor:"white",height:"2px",width:"100%"}}/>
17+
<hr style={{backgroundColor:"white",height:"2px",width:"100%",filter:"blur(3px)"}}/>
1618
</article>
1719
))
1820
}
1921

22+
const listAndDisplayAllTheCategories =() =>{
23+
return categories.map((cat,index)=>{
24+
return (
25+
<Link href={`/categories/${cat.slug}`} key={index}>
26+
<a className="btn btn-sm btn-success mr-1 ml-1 mt-3">{cat.name}</a>
27+
</Link>
28+
)
29+
})
30+
};
31+
32+
const listAndDisplayAllTheTaglists =() =>{
33+
return taglists.map((tagg,index)=>{
34+
return (
35+
<Link key={index} href={`/taglists/${tagg.slug}`}>
36+
<a className="btn btn-sm btn-info mr-1 ml-1 mt-3 mb-4">{tagg.name}</a>
37+
</Link>
38+
)
39+
})
40+
};
41+
2042
return (
2143
<>
2244
<Layout>
@@ -27,7 +49,13 @@ const Blogs = ({blogs,categories,taglists,size}) => {
2749
<h1 className="display-4 font-weight-bold text-center">Tech Blogs</h1>
2850
</div>
2951
<section>
30-
<p>show categories and tags</p>
52+
<div className="pb-5 text-center">
53+
<CategoryIcon style={{color:"limegreen"}}/>{listAndDisplayAllTheCategories()}
54+
<br/>
55+
<LabelIcon style={{color:"teal"}}/>{listAndDisplayAllTheTaglists()}
56+
{/* {JSON.stringify(taglists)} */}
57+
{/* {JSON.stringify(categories)} */}
58+
</div>
3159
</section>
3260
</header>
3361
</div>

server/controllers/blog.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ exports.bloglistsallCategoriesTags =(req,res)=>{
160160
error: errorHandler(err)
161161
})
162162
}
163-
tags = tagg
163+
taglists = tagg
164164
// return all the categories ,tags and the blogs
165-
res.json({blogs,categories,tags,size: blogs.length});
165+
res.json({blogs,categories,taglists,size: blogs.length});
166166
})
167167
})
168168
})

0 commit comments

Comments
 (0)