Closed sangdth closed 6 years ago
Hey @sangdth here's how I would do it.
For each post you're going to get the slug as part of the post object. For your link to that post you'll want to do a <router-link :to="'/posts/'+post.slug"></router-link>
Then in your router you would do:
{
// How to dynamic detect the path?
path: '/posts/:slug',
component: SinglePost
}
One of the costs of replacing the WordPress theme with a Vue app is that we lose access to some of those handy WordPress functions, unless of course we leverage those to modify the JSON response from the API.
Thanks, it works.
Awesome, feel free to open a PR if you think your changes might be beneficial to the project!
Hi Evan,
I'm trying to display single post, I've created a SinglePost.vue, add object into
/router/index.js
Right now I'm cheating, he he, change the permalink into "postname" only, to make it easy.
My question is, in WP we have many ways to display the path, from date
/2017/10/18/hello-world
, to category like/cagegory/hello-world
, how could we get it and put it into thepath
programmatically?Thanks.