v1.18.x
Julian Lam 11 years ago
parent 5546b4e04d
commit 8e0bc0257d

@ -9,6 +9,7 @@ var path = require('path'),
topics = require('./topics'), topics = require('./topics'),
utils = require('../public/src/utils'), utils = require('../public/src/utils'),
sitemap = { sitemap = {
obj: undefined,
getStaticUrls: function(callback) { getStaticUrls: function(callback) {
callback(null, [{ callback(null, [{
url: '', url: '',
@ -74,17 +75,28 @@ var path = require('path'),
}); });
}, },
render: function(callback) { render: function(callback) {
async.parallel([sitemap.getStaticUrls, sitemap.getDynamicUrls], function(err, urls) { var returnSitemap = function() {
urls = urls[0].concat(urls[1]); sitemap.obj.toXML(function(xml) {
var map = sm.createSitemap({ callback(xml);
});
};
if (sitemap.obj !== undefined && sitemap.obj.cache.length) {
console.log('using sitemap from cache!');
returnSitemap();
} else {
console.log('generating new sitemap!', sitemap.obj);
async.parallel([sitemap.getStaticUrls, sitemap.getDynamicUrls], function(err, urls) {
urls = urls[0].concat(urls[1]);
sitemap.obj = sm.createSitemap({
hostname: nconf.get('url'), hostname: nconf.get('url'),
cacheTime: 60*60, // Cached for 1 hour cacheTime: 1000 * 60 * 60, // Cached for 1 hour
urls: urls urls: urls
}),
xml = map.toXML(function(xml) {
callback(xml);
}); });
});
returnSitemap();
});
}
} }
}; };

Loading…
Cancel
Save