meteor-sitemaps icon indicating copy to clipboard operation
meteor-sitemaps copied to clipboard

Dynamic Sitemaps

Open fr33dr4g0n opened this issue 10 years ago • 1 comments

How to do dynamic sitemaps when I have something like this with Iron router:

this.route('/analytics/:_id/:name', {
   template: 'analyticsDetails',
    waitOn: function() {
        return Meteor.subscribe('Analytics', {
            _id: this.params._id
        })
    },
    data: function() {
        return Analytics.findOne(this.params._id);
    },
    onAfterAction: function () {
        SEO.set({
            title: this.params.name + " | GrowthTools.io",
            description: this.params.functionality
        });
    }
})

fr33dr4g0n avatar Oct 13 '15 12:10 fr33dr4g0n

Hey @fr33dr4g0n, sitemaps is completely independent of routing, and is coupled directly to the database. For this kind of setup you'd do:

sitemaps.add('/sitemap.xml', function() {
  var out = [], analytics = Analytics.find().fetch();
  _.each(analytics, function(page) {
    out.push({
      page: '/analytics/' + page._id + '/' + page.name
      // lastmod: page.lastUpdated etc...
    });
  });
  return out;
});

All on the server, of course.

gadicc avatar Oct 14 '15 08:10 gadicc