meteor-sitemaps
meteor-sitemaps copied to clipboard
Dynamic Sitemaps
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
});
}
})
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.