how to append slug at the end of URL after loading page
-
can someone point me out in the right direction how can we add route slug at the end of the URL after user navigation … i would like to build the same functionality like the quasar framework forum routing … when the user enters direct link like this one -
https://forum.quasar-framework.org/topic/2927
after the route is navigated the post title slug is appended at the end of the link
https://forum.quasar-framework.org/topic/2927/sanitizing-labels-preventing-xss-attacks
-
I am going to try and take a stab at this…
In yoursrc/router/routes.js
file, as child data inchildren
you would have the following:{ path: 'topic/:topicId', component: () => import('pages/DisplayTopic') // <== name of page },
Then, on that page, you can access it like this:
this.$route.params.topicId
You can read up on it here: https://router.vuejs.org/guide/essentials/passing-props.html#boolean-mode
-
This can best be done server side and that will depend on your server language but will be whatever is handling your routes. So to better explain, you will do a 302 redirect when someone hits a route with topic id and redirect them to the correct url. (Not sure but I think this is how the forum here does it)
And for the slug you can either store ahead of time in your db or create it on the fly from the title (I prefer the first one)
Now if you don’t have access to the backend, another way would be using vueRouter (haven’t tested this one and personally prefer the one above) but if you need help on that let me know.
-
Thank you guys ! i’ll do some experiments and will let you know about the results