This episode is for members only

Sign up to access "Build A Static File Blog with Laravel" right now.

Get started
Already a member? Sign in to continue
Playing
07. Showing individual blog posts

Transcript

00:00
Now that we have got the correct post, we can just go ahead and return a view here and show this blog post. And this is going to be super simple because we know that we've got our Tailwind typography package pulled in, which is going to make styling this really simple. So I'm just going to create our posts show.blade.php file, and over in our post show controller,
00:19
we can now go ahead and return out a view here. So that will now be posts and show, and we can just go ahead and pass that post down much like we would normally do. Okay, so over in show.blade.php, let's open this up and let's style this out. So again, we're using our app layout, so it's going to be exactly the same thing.
00:40
And then in here, we're going to have an article and we're going to style this up with our prose. We'll say prose, what did we say before large, I think. And then in here, just output an h1 with the post title. So we can access any of these attributes. We can go ahead and create a div out here with the post teaser, like so. And then let's steal what we did over here with
01:05
the author and the date. So let's pull that down just below here. So heading over and giving that a refresh, there we go. There is our blog. Now I've gone ahead and used the teaser here. That is of course not what we want to do. We're now accessing the contents of this, which if we head over to one of our posts is not great at the moment. So we'll go ahead and fill that in.
01:25
But there we go. There's the actual body of our blog post. Okay, so I'm going to go ahead and just pull over some content here that I pre-made. You can of course grab this from the GitHub repository if you want to. This has got some code in at the moment. We'll go ahead and leave this in for now just so we can see what happens. But we've at least got a little bit more content in
01:47
there now. Okay, so we do have syntax highlighting because with Markdown, this will always render out a syntax highlighting. But we are going to change this over to use something a little bit better. But as you can see, the article is being rendered. We can head back. We can choose another blog post. It works in exactly the same way. We won't bother filling the body in for this.
02:06
But for example, over on this blog post, if we wanted to go ahead and update this to include some Markdown, we can very easily do that in there. And that's going to work. Let's go ahead and make that bold actually. And there we go. So everything is looking good. Super simple now to just create a new file, add in the metadata we need, and just start writing these out in Markdown.
13 episodes1 hr 11 mins

Overview

Let's build a ridiculously fast blog from scratch in Laravel, entirely driven by markdown files. No database required!

Your blog will feature everything you're used to, like syntax highlighting, post tagging and pagination. Plus, it'll render in record time.

Once you're done with the course, you'll be able to add on additional features with ease, style it up how you want and quickly create new posts since there's no need for an admin panel.

Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Comments

No comments, yet. Be the first to leave a comment.