url rewriting - Dynamic URL variable for SEO with Meteor -
i'm working on meteor app uses ms-seo package. wondering if there way make urls more seo friendly?
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 } }); } });
while works perfect, url produces /item/5rtxofppn3lwifp24
, push data.title
in url, can /item/i-am-a-lower-case-dash-replaced-unique-title/
are there packages that?
you need create slug. collection have fields like:
- _id
- title
- slug
- content
then make slug can use https://atmospherejs.com/yasaricli/slugify convert title slug. convert title called "unique shopping cart item" "unique-shopping-cart-item."
then in router pass slug in parameter.
router.route('/blog/:slug',{ name:'blogposts', waiton: function() { return meteor.subscribe('collection'); }, data: function(){ var slug = this.params.slug; return collection.findone({slug:slug}); // saying search collection's slug passed in parameter we're calling "slug" } });
Comments
Post a Comment