Authored by 周少峰

301, page url

... ... @@ -55,10 +55,28 @@ const keywordsPage = () => {
});
};
// 逛详情
const getArticleUrls = () => {
let urls = [];
return Service.get('/guang/api/v2/article/getLastArticleList', {limit: 1000}, {cache: 86400}).then(res => {
_.forEach(_.get(res, 'data.artList', ''), val => {
urls.push({
url: `https:${helpers.urlFormat(`/guang/${val.articleId}.html`, null)}`,
changefreq: 'daily',
priority: 0.3
});
});
return urls;
});
};
// www 地图数据
const wwwXmlData = () => {// eslint-disable-line
return Promise.all([keywordsPage(), getStaticUrls(_.get(staticUrls, 'www'))]).then(result => {
return _.concat(result[1], result[0]);
return Promise.all([keywordsPage(), getStaticUrls(_.get(staticUrls, 'www')), getArticleUrls()]).then(result => {
return _.concat(result[1], result[0], result[2]);
});
};
... ... @@ -104,34 +122,10 @@ const itemXmlData = () => {// eslint-disable-line
});
};
const getArticleUrls = () => {
let urls = [];
return Service.get('/guang/api/v2/article/getLastArticleList', {limit: 1000}, {cache: 86400}).then(res => {
_.forEach(_.get(res, 'data.artList', ''), val => {
urls.push({
url: `https:${helpers.urlFormat(`/${val.articleId}.html`, '', 'guang')}`,
changefreq: 'daily',
priority: 0.3
});
});
return urls;
});
};
// guang 地图数据
const guangXmlData = () => {// eslint-disable-line
return Promise.all([getStaticUrls(_.get(staticUrls, 'guang')), getArticleUrls()]).then(res => {
return _.union(res[0], res[1]);
});
};
// 站点地图
const siteMap = (req, res, next) => {
let siteList = ['www', 'list', 'item', 'guang'],
let siteList = ['www', 'list', 'item'],
subdomain = req.subdomains[0] || 'www';
if (_.find(siteList, subdomain)) {
... ...
... ... @@ -78,20 +78,16 @@ module.exports = class extends global.yoho.BaseModel {
return query ? _.concat(path, [{ name: query, pathTitle: query}]) : path;
}
_formatTag(tagData, channel) {
_formatTag(tagData) {
let name = tagData.name,
param = {
query: name
};
if (channel) {
param.channel = channel;
}
return {
tag: name,
name: name,
url: helpers.urlFormat('/tags/index', param, 'guang')
url: helpers.urlFormat('/guang/tags/index', param)
};
}
... ... @@ -412,13 +408,9 @@ module.exports = class extends global.yoho.BaseModel {
query: it.tag_name
};
if (channel) {
param.channel = channel;
}
return {
tagName: it.tag_name,
url: helpers.urlFormat('/tags/index', param, 'guang')
url: helpers.urlFormat('/guang/tags/index', param)
};
});
});
... ...
... ... @@ -7,9 +7,9 @@
const helpers = global.yoho.helpers;
module.exports.editorUrl = function(channel, authorId) {
return helpers.urlFormat(`/author-${channel}-${authorId}/`, null, 'guang');
return helpers.urlFormat(`/guang/author-${channel}-${authorId}/`, null);
};
module.exports.listUrl = function(channel, type) {
return helpers.urlFormat(`/${channel}-t${type}/`, null, 'guang');
return helpers.urlFormat(`/guang/${channel}-t${type}/`, null);
};
... ...
... ... @@ -39,6 +39,13 @@ module.exports = {
lastmod: today,
changefreq: 'daily',
priority: 0.3
},
guang: {
loc: ['https://www.yohobuy.com/guang/'],
lastmod: today,
changefreq: 'daily',
priority: 0.3
}
},
... ... @@ -68,14 +75,6 @@ module.exports = {
priority: 0.3
},
// 逛 编辑列表/标签列表/逛详情动态添加
guang: {
loc: ['https://guang.yohobuy.com/boys/', 'https://guang.yohobuy.com/girls/', 'https://guang.yohobuy.com/kids/', 'https://guang.yohobuy.com/lifestyle/'],
lastmod: today,
changefreq: 'daily',
priority: 0.3
},
// 商品详情动态添加
item: {
loc: [],
... ...
... ... @@ -7,108 +7,12 @@
const helpers = global.yoho.helpers;
const TYPE = require('../type');
const MOBILE_DOMAIN = '//guang.m.yohobuy.com';
module.exports = [
// 老的首页
{
type: TYPE.redirect,
origin: (req) => {
return req.path === '/';
},
origin: /^\/(.*)/,
target: (req) => {
return helpers.urlFormat(`/${req.yoho.channel}/`, null, 'guang');
}
},
// 首页
{
type: TYPE.rewrite,
origin: /^\/(boys|girls|kids|lifestyle)(\/*)$/,
target: (req, match, channel) => {
req.query.channel = channel;
return `/guang/?chanel=${channel}`;
}
},
// 老的首页 + 类型 + 翻页
{
type: TYPE.redirect,
origin: req => /index\/index/i.test(req.path),
target: (req) => {
return helpers.urlFormat(
`/${req.yoho.channel}-t${req.query.type || 0}${req.query.page ? '-p' + req.query.page : ''}/`,
null,
'guang'
);
}
},
// 首页 + 类型
{
type: TYPE.rewrite,
origin: /^\/(boys|girls|kids|lifestyle)-t([\d]+)(\/*)$/,
target: (req, match, channel, type) => {
req.query.channel = channel;
req.query.type = type;
return `/guang/?chanel=${channel}&type=${type}`;
}
},
// 列表页 + 类型 + 翻页
{
type: TYPE.rewrite,
origin: /^\/(boys|girls|kids|lifestyle)-t([\d]+)-p([\d]+)(\/*)$/,
target: (req, match, channel, type, page) => {
req.query.channel = channel;
req.query.type = type;
req.query.page = page;
return `/guang/index/index/?type=${type}&channel=${page}`;
}
},
// 老的编缉首页
{
type: TYPE.redirect,
origin: (req) => {
return /index\/editor/i.test(req.path);
},
target: (req) => {
let channel = req.yoho.channel;
let authorId = req.query.author_id;
let page = req.query.page;
if (!authorId) {
return helpers.urlFormat(`/${channel}/`, null, 'guang');
}
return helpers.urlFormat(`/author-${channel}-${authorId}${page ? '-p' + page : ''}/`, null, 'guang');
}
},
// 编缉首页
{
type: TYPE.rewrite,
origin: /^\/author-(boys|girls|kids|lifestyle)-([\d]+)(\/*)$/,
target: (req, match, channel, authorId) => {
req.query.channel = channel;
req.query.author_id = authorId;
req.mobileUrl = `${MOBILE_DOMAIN}/author-${channel}-${authorId}/`;
return `/guang/index/editor?channel=${channel}&author_id=${authorId}`;
}
},
// 编缉首页 + 翻页
{
type: TYPE.rewrite,
origin: /^\/author-(boys|girls|kids|lifestyle)-([\d]+)-p([\d]+)(\/*)$/,
target: (req, match, channel, authorId, page) => {
req.query.channel = channel;
req.query.author_id = authorId;
req.query.page = page;
req.mobileUrl = `${MOBILE_DOMAIN}/author-${channel}-${authorId}-p${page}/`;
return `/guang/index/editor?channel=${channel}&author_id=${authorId}&page=${page}`;
return helpers.urlFormat(`/guang${req.url}`, null);
}
}
];
... ...