next-netlify-blog-starter
next-netlify-blog-starter copied to clipboard
Full page refresh when clicking blog posts.
Hi!
I just went through your blog post on Netlify and was going to compare what I had just learned on Next's learn-starter blog to see what you both did differently for my own curiosities (still processing).
I noticed though when I clicked a blog post (from post list on the index page) I would get a full-page refresh when going to the blog post. I couldn't see what I did wrong so I came here to clone this repo and I got the same behaviour.
I preserved my logs and this is what I get:
![CleanShot 2020-05-14 at 22 45 43@2x](https://user-images.githubusercontent.com/19172250/82006326-865e9500-9635-11ea-803b-631f1d5603ae.png)
But the post will still show up, but first it get's an error and refreshes.
Do you not get this behaviour? Not quite sure what's up 🤷🏽♂️
Hey, the issue happens because the <Link />
in the PostLink component should point to a dynamic route.
You can find more info about it in the docs.
Here's a working version:
<Link href="/posts/[postname]" as={`/posts/${post.slug}`}>
<a>{post.frontmatter.title}</a>
</Link>
Ah good call, missing the as
attribute! Ty