Authored by yyq

Merge remote-tracking branch 'origin/feature/guangSitemap' into release/1026

Too many changes to show.

To preserve performance only 1 of 1+ files are displayed.

... ... @@ -8,6 +8,7 @@ const staticUrls = require('../../../config/staticUrls');
const api = global.yoho.API;
const Service = global.yoho.ServiceAPI;
const headerModel = require('../../../doraemon/models/header');
const siteMapService = require('../models/site-map-service');
const redis = global.yoho.redis;
... ... @@ -156,6 +157,43 @@ const siteMap = (req, res, next) => {
}).catch(next);
};
const _createSitemap = (req, res, rdata, startUrl, endUrl) => {
sm.createSitemap({
hostname: 'https://www.yohobuy.com',
xmlNs: ' ',
urls: _.map(rdata, id => {
return {
url: `${startUrl}${id}${endUrl}`,
changefreq: 'daily',
priority: 0.3
};
})
}).toXML(function(err, xml) {
rdata = [];
if (err) {
return res.status(500).end();
}
res.header('Content-Type', 'application/xml');
res.send(xml);
});
};
const guangMap = (req, res, next) => {
req.ctx(siteMapService).guangList().then(rdata => {
return _createSitemap(req, res, rdata, 'https://www.yohobuy.com/guang/', '.html');
}).catch(next);
};
const newsMap = (req, res, next) => {
req.ctx(siteMapService).newsList(1, []).then(rdata => {
return _createSitemap(req, res, rdata, 'https://www.yohobuy.com/news/', '.html');
}).catch(next);
};
module.exports = {
siteMap
siteMap,
guangMap,
newsMap
};
... ...