Reputation: 2288
Currently I have
http://www.example.com/videos/videoId
In my iron router,
Router.route('/videos/:_id', { name: 'videoShowtemplate' }
I want to make my site more seo friendly so I was thinking of adding the video title to the URL.
http://www.example.com/videos/videoId/videoTitle
can you tell me how i can do this? thank you very much in advance.
Upvotes: 0
Views: 121
Reputation: 3043
Go through the docs: https://github.com/EventedMind/iron-router/blob/devel/Guide.md
Keep the same route and just add /:slug to your params.
Do all your validations on _id
Router.route('/videos/:_id/:slug', {
template: 'videoShowtemplate'
}
use the following code to redirect to the site
in html
<a href="/videos/{{_id}}/{{title}}">click here</a>
or in js
Router.go('videoShowtemplate', {_id: id,slug: title});
Upvotes: 2