...
|
...
|
@@ -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,44 @@ 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(1, []).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
|
|
|
}; |
...
|
...
|
|