Authored by 周少峰

list

... ... @@ -7,7 +7,6 @@ const sm = require('sitemap');
const staticUrls = require('../../../config/staticUrls');
const api = global.yoho.API;
const Service = global.yoho.ServiceAPI;
const headerModel = require('../../../doraemon/models/header');
const getStaticUrls = (currentStatics) => {
let urls = [];
... ... @@ -34,36 +33,6 @@ const getStaticUrls = (currentStatics) => {
return Promise.resolve(urls);
};
// m 地图数据
const mXmlData = () => {// eslint-disable-line
return getStaticUrls(_.get(staticUrls, 'm'));
};
// list 地图数据
const listXmlData = () => {// eslint-disable-line
return Promise.all([getStaticUrls(_.get(staticUrls, 'list')), headerModel.requestHeaderData()]).then(result => {
// 获取导航中的列表链接
let listNav = [],
listPatten = /list\.yohobuy\.com/;
_.forEach(_.get(result[1], 'headerData.subNavGroup'), val => {
_.forEach(val.subNav, sub => {
if (listPatten.test(sub.link)) {
listNav.push({url: `https:${sub.link}`, changefreq: 'daily', priority: 0.3});
}
_.forEach(_.get(sub, 'thirdNav'), third => {
if (listPatten.test(third.link)) {
listNav.push({url: `https:${third.link}`, changefreq: 'daily', priority: 0.3});
}
});
});
});
return _.union(result[0], _.uniqBy(listNav, 'url'));
});
};
// item 地图数据
const itemXmlData = () => {// eslint-disable-line
let urls = [];
... ... @@ -71,7 +40,7 @@ const itemXmlData = () => {// eslint-disable-line
return api.get('', {method: 'web.product.bdPromotion'}, {cache: 86400}).then(res => {
_.forEach(_.get(res, 'data', ''), val => {
urls.push({
url: `https:${helpers.getUrlBySkc(val.id)}`,
url: 'https:' + helpers.urlFormat(`/product/${val.id}.html`, '', null),
changefreq: 'daily',
priority: 0.3
});
... ... @@ -81,6 +50,18 @@ const itemXmlData = () => {// eslint-disable-line
});
};
// m 地图数据
const mXmlData = () => {// eslint-disable-line
return Promise.all([getStaticUrls(_.get(staticUrls, 'm')), itemXmlData()]).then(result => {
return _.union(result[0], result[1]);
});
};
// list 地图数据
const listXmlData = () => {// eslint-disable-line
return getStaticUrls(_.get(staticUrls, 'list'));
};
const getArticleUrls = () => {
let urls = [];
... ... @@ -107,15 +88,13 @@ const guangXmlData = () => {// eslint-disable-line
// 站点地图
const siteMap = (req, res, next) => {
let siteList = ['m', 'list', 'item', 'guang'],
subdomain = req.subdomains[0] || 'm';
subdomain = req.subdomains[1] || 'm';
if (_.find(siteList, subdomain)) {
res.end('end');
return;
}
eval(subdomain + 'XmlData')().then(urls => {// eslint-disable-line
sm.createSitemap({
hostname: `https://${subdomain}.yohobuy.com`,
... ...
... ... @@ -10,7 +10,7 @@ module.exports = {
m: {
// 频道
channel: {
loc: ['https:m.yohobuy.com/', 'https://m.yohobuy.com/girls/', 'https://m.yohobuy.com/kids/', 'https://m.yohobuy.com/lifestyle/'],
loc: ['https://m.yohobuy.com/', 'https://m.yohobuy.com/girls/', 'https://m.yohobuy.com/kids/', 'https://m.yohobuy.com/lifestyle/'],
lastmod: today,
changefreq: 'daily',
priority: 0.8
... ... @@ -271,9 +271,9 @@ module.exports = {
},
guang: {
loc: ['https://guang.m.yohobuy.com/?gender=1%2C3', 'https://guang.m.yohobuy.com/?gender=2%2C3', 'https://guang.m.yohobuy.com/?gender=1%2C2%2C3', 'https://guang.m.yohobuy.com/?id=2&name=%E6%90%AD%E9%85%8D', 'https://guang.m.yohobuy.com/?id=4', 'http://guang.m.yohobuy.com/?id=0', 'https://guang.m.yohobuy.com/?id=1', 'https://guang.m.yohobuy.com/?id=3', 'https://guang.m.yohobuy.com/?id=5',
'https://guang.m.yohobuy.com/guang/author-8168253/', 'https://guang.m.yohobuy.com/guang/author-8168291', 'https://guang.m.yohobuy.com/guang/author-8168283', 'https://guang.m.yohobuy.com/guang/author-8168239', 'https://guang.m.yohobuy.com/guang/author-8168287', 'https://guang.m.yohobuy.com/guang/author-8168287', 'https://guang.m.yohobuy.com/guang/author-8168259', 'https://guang.m.yohobuy.com/guang/author-7823335', 'https://guang.m.yohobuy.com/guang/author-8123505',
'https://guang.m.yohobuy.com/guang/author-6875335', 'https://guang.m.yohobuy.com/guang/author-8168275', 'https://guang.m.yohobuy.com/guang/author-8168289', 'https://guang.m.yohobuy.com/guang/author-8168257', 'https://guang.m.yohobuy.com/guang/author-8168265', 'https://guang.m.yohobuy.com/guang/author-8168271', 'https://guang.m.yohobuy.com/guang/author-8168227', 'https://guang.m.yohobuy.com/guang/author-8168244', 'https://guang.m.yohobuy.com/guang/author-8168255',
'https://guang.m.yohobuy.com/guang/author-8168248', 'https://guang.m.yohobuy.com/guang/author-380463'],
'https://guang.m.yohobuy.com/guang/author-8168253/', 'https://guang.m.yohobuy.com/guang/author-8168291/', 'https://guang.m.yohobuy.com/guang/author-8168283/', 'https://guang.m.yohobuy.com/guang/author-8168239/', 'https://guang.m.yohobuy.com/guang/author-8168287/', 'https://guang.m.yohobuy.com/guang/author-8168287/', 'https://guang.m.yohobuy.com/guang/author-8168259/', 'https://guang.m.yohobuy.com/guang/author-7823335/', 'https://guang.m.yohobuy.com/guang/author-8123505/',
'https://guang.m.yohobuy.com/guang/author-6875335/', 'https://guang.m.yohobuy.com/guang/author-8168275/', 'https://guang.m.yohobuy.com/guang/author-8168289/', 'https://guang.m.yohobuy.com/guang/author-8168257/', 'https://guang.m.yohobuy.com/guang/author-8168265/', 'https://guang.m.yohobuy.com/guang/author-8168271/', 'https://guang.m.yohobuy.com/guang/author-8168227/', 'https://guang.m.yohobuy.com/guang/author-8168244/', 'https://guang.m.yohobuy.com/guang/author-8168255/',
'https://guang.m.yohobuy.com/guang/author-8168248/', 'https://guang.m.yohobuy.com/guang/author-380463/'],
lastmod: today,
changefreq: 'daily',
priority: 0.3
... ...