Meteor搜索引擎优化的动态URL变量

Meteor搜索引擎优化的动态URL变量,meteor,url-rewriting,seo,iron-router,Meteor,Url Rewriting,Seo,Iron Router,我正在开发一个Meteor应用程序,它使用。我想知道是否有一种方法,使网址搜索引擎优化更友好 Router.route('/item/:_id', { name: 'item.detail', controller: 'ItemsController', action: 'detail', where: 'client', onAfterAction: function() { var data = this.data(); if (data) { S

我正在开发一个Meteor应用程序,它使用。我想知道是否有一种方法,使网址搜索引擎优化更友好

Router.route('/item/:_id', {
  name: 'item.detail',
  controller: 'ItemsController',
  action: 'detail',
  where: 'client',
  onAfterAction: function() {
    var data = this.data();
    if (data) {
    SEO.set({
      title: data.title + ' - ' + data.company + ' (' + data.city + ')',
      meta: {
        'description': data.descriptionHTML
      }
    });
  }
});
虽然这很好用,但它生成的URL是/item/5RTxofPPn3LwifP24,我想在URL中向上推data.title,这样我就可以得到/item/I-am-a-lower-case-dash-replacemented-unique-title/


有软件包吗?

您需要创建一个slug。因此,您的集合将包含如下字段:

_身份证 标题 鼻涕虫 所容纳之物 然后,为了制作你的slug,你可以使用类似的东西将你的标题转换成slug。基本上,它所做的是将名为Unique Shopping Cart Item的标题转换为Unique Shopping Cart Item

然后在您的路由器中,您将slug作为参数传入

Router.route('/blog/:slug',{
    name:'blogPosts',
    waitOn: function() { return Meteor.subscribe('collection'); },
    data: function(){
        var slug = this.params.slug;
        return Collection.findOne({slug:slug});
        // this is saying search the collection's slug for the passed in parameter which we're also calling "slug"
    }
});

您可以尝试将data.title作为一个漂亮的url推送

谢谢你的建议