向URL Meteor Iron路由器添加标题
目前我有向URL Meteor Iron路由器添加标题,url,meteor,iron-router,Url,Meteor,Iron Router,目前我有 http://www.example.com/videos/videoId 在我的铁制路由器里 Router.route('/videos/:_id', { name: 'videoShowtemplate' } 我想让我的网站更seo友好,所以我想添加 URL的视频标题 http://www.example.com/videos/videoId/videoTitle 你能告诉我怎么做吗?提前非常感谢。浏览文档: 保持相同的路线,只需将/:slug添加到参数中 在\u id Ro
http://www.example.com/videos/videoId
在我的铁制路由器里
Router.route('/videos/:_id', { name: 'videoShowtemplate' }
我想让我的网站更seo友好,所以我想添加
URL的视频标题
http://www.example.com/videos/videoId/videoTitle
你能告诉我怎么做吗?提前非常感谢。浏览文档:
保持相同的路线,只需将/:slug添加到参数中
在\u id
Router.route('/videos/:_id/:slug', {
template: 'videoShowtemplate'
}
使用以下代码重定向到站点
在html中
<a href="/videos/{{_id}}/{{title}}">click here</a>
这么说slug什么也没做?像/videos/videoId/title1和/videos/videoId/title2一样,只要ID相同,就会指向同一个视频?是的,如果你想让slug做些什么,那么在搜索视频时,将slug添加到查询
videos.findOne({u ID:ID,title:slug})代码>仅当两者匹配时才会返回视频
Router.go('videoShowtemplate', {_id: id,slug: title});