url中的博客名称而不是meteor中的id

url中的博客名称而不是meteor中的id,meteor,iron-router,Meteor,Iron Router,我有一个博客,我想在如何做到这一点的博客文章名,而不是博客id 我希望url像mysite.com/firs post而不是像mysite.com/\u id 代码 博客帖子名称可能重复 I want to redirect to particular blog post without the id in url 一个想法是在模板上有一个链接,例如: <a href="/blog_post_name"></a> 为此,我使用博客名和记录id(最后5个字母)创建了一个

我有一个博客,我想在如何做到这一点的博客文章名,而不是博客id

我希望url像
mysite.com/firs post
而不是像
mysite.com/\u id

代码

博客帖子名称可能重复

I want to redirect to particular blog post without the id in url

一个想法是在模板上有一个链接,例如:

<a href="/blog_post_name"></a>

为此,我使用博客名和记录id(最后5个字母)创建了一个链接


post-name-xh45d

是否要在模板事件上重定向?点击一个链接?想了想,但是当我们刷新页面或者当用户从另一个站点转到特定的url时,它将不起作用。我想要隐藏id之类的东西:)这将不起作用,因为正如我在问题中所说的,可能有重复的博客标题,所以当我们找到它时,它会返回它找到的第一条记录
<a href="/blog_post_name"></a>
 Router.map("blogpost",{
     path:"/blog/:slug",
     template:"singlepost",
     waitOn: function () {
         return [Meteor.subscribe('blog')];
     },
     data: function(){
         return blog.findOne({name: this.params.slug});//want to return single blog
     }
 });