In this section we will make it so that we can go to the Read More
link, click on it, it'll show us the entire post and we'll also have comment functionality:
We want to do first is go in to route and then post.js
and let's copy this:
router.get('/add', function(req, res, next) { var categories = db.get('categories'); categories.find({},{},function(err, categories){ res.render('addpost',{ 'title': 'Add Post', 'categories': categories }); }); });
And what we will do is say get/show/:id
and then what we want to do is change this to posts
, get('posts')
and then change that to posts
. And next we will pass functions to findById
where we can actually get rid of these two and then we just want to pass in req.params.id
:
router.get('/show/:id', function(req, res, next) { var posts = db.get('posts'); posts.findById(req.params.id,function(err, post){ res.render('show',{ 'post': post }); }); });
Then we will...