0 1 00:00:00,270 --> 00:00:03,800 All right. Are you ready for challenge 19? 1 2 00:00:04,410 --> 00:00:09,420 All right so here's the goal of this challenge. Instead of console logging whether something matched 2 3 00:00:09,420 --> 00:00:10,440 or not match, 3 4 00:00:10,440 --> 00:00:18,150 we actually want to render the actual page so that if we have a post say called another post inside 4 5 00:00:18,150 --> 00:00:25,170 our home page we should be able to head over to /posts/another-post. 5 6 00:00:25,170 --> 00:00:31,830 And the goal of this challenge is that when I hit enter we should now get taken to a brand new page 6 7 00:00:32,010 --> 00:00:40,080 that's been rendered using EJS and it's a standalone page that just contains the contents of that particular 7 8 00:00:40,080 --> 00:00:41,290 blog post. 8 9 00:00:41,430 --> 00:00:47,100 And if I had more than one post say if I had another post-coup Day 2 as the title, then I should be 9 10 00:00:47,100 --> 00:00:53,100 able to navigate to it by simply going to /posts/day-2. And now when I hit 10 11 00:00:53,130 --> 00:00:58,740 enter I get taken to another page, a brand new page for this blog post. 11 12 00:00:58,780 --> 00:01:05,130 And no matter how many new posts that you compose every single one of them should dynamically get its 12 13 00:01:05,190 --> 00:01:13,070 own page just by using EJS and our Express routing parameters. Inside the views folder 13 14 00:01:13,080 --> 00:01:17,460 you should notice that you already have a empty file called post. 14 15 00:01:17,490 --> 00:01:18,350 ejs. 15 16 00:01:18,630 --> 00:01:22,210 See how you can use this along with what we've got so far 16 17 00:01:22,290 --> 00:01:28,150 in order to create this outcome. Pause the video and complete the challenge. 17 18 00:01:28,180 --> 00:01:32,670 Now my first hint for you is that you don't need this else statement any more. 18 19 00:01:32,670 --> 00:01:38,240 You're only checking to see if the requestedTitle is equal to the storedTitle. And in that case instead 19 20 00:01:38,290 --> 00:01:46,210 of console logging, you want to send people over to this posts.ejs page. And you need to render this 20 21 00:01:46,210 --> 00:01:54,480 page such that it gets access to the title and the content of the post that is being requested. 21 22 00:01:54,490 --> 00:02:00,480 You will need to decide on some variable names for what you want to pass over using EJS, 22 23 00:02:00,580 --> 00:02:06,910 you'll have to add the layouts the header and footer just as we have done for all the other pages and 23 24 00:02:06,910 --> 00:02:14,080 then you have to use the EJS tags in order to render an h1 and a paragraph tag of the title and 24 25 00:02:14,080 --> 00:02:15,090 the body. 25 26 00:02:15,430 --> 00:02:21,010 So see if this is enough of a hint for you to now be able to complete the challenge. 26 27 00:02:21,040 --> 00:02:28,150 Now the second hnt if you need it is that remember how we rendered our home page right? 27 28 00:02:28,180 --> 00:02:31,250 We actually used a method called res.render. 28 29 00:02:31,270 --> 00:02:36,580 Seems like a long time ago but we use res.render and then we specify the name of the page that 29 30 00:02:36,580 --> 00:02:42,940 we want to render and then we added a comma and then we specified a Javascript object where we have 30 31 00:02:43,150 --> 00:02:49,450 a key and a value and the value is the thing that we want to pass over and the key is the thing that 31 32 00:02:49,450 --> 00:02:53,350 we get to access inside that target page. 32 33 00:02:53,350 --> 00:02:57,360 So with this final hint see if you can now complete the challenge.