Authored by 毕凯

Merge branch 'feature/seo2' into 'gray'

guang 链接变短



See merge request !1106
... ... @@ -92,13 +92,13 @@ const _relatedInfo = (getOtherArticle, isApp) => {
if (value.url.indexOf('guang.m.yohobuy.com') < 0) {
value.url = `${helpers.https(value.url)}?openby:yohobuy={"url":"${value.url}","islogin":"N"}}`;
} else {
value.url = `//m.yohobuy.com/guang/info/${value.id}.html?openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${value.id}"},"shareparam":{"id":"${value.id}"},"share":"/guang/api/v1/share/guang","id":${value.id},"type":1,"url":"http://m.yohobuy.com/guang/info/${value.id}.html","islogin":"N"}}`;
value.url = `//m.yohobuy.com/guang/${value.id}.html?openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${value.id}"},"shareparam":{"id":"${value.id}"},"share":"/guang/api/v1/share/guang","id":${value.id},"type":1,"url":"http://m.yohobuy.com/guang/${value.id}.html","islogin":"N"}}`;
}
} else {
if (value.url.indexOf('guang.m.yohobuy.com') < 0) {
value.url = value.url;
} else {
value.url = `//m.yohobuy.com/guang/info/${value.id}.html`;
value.url = `//m.yohobuy.com/guang/${value.id}.html`;
}
}
... ... @@ -312,7 +312,7 @@ const indexRedirect = (req, res, next) => {
let id = req.query.id;
if (id) {
let redirectUrl = '/guang/info/';
let redirectUrl = '/guang/';
if (req.yoho.channel !== req.cookies._Channel) {
redirectUrl += `${req.yoho.channel}-`;
... ...
... ... @@ -261,9 +261,23 @@ module.exports = class extends global.yoho.BaseModel {
data.url = data.url + '';
}
if (isApp) {
if (data.url.indexOf('guang.m.yohobuy.com') < 0) {
data.url = `${helpers.https(data.url)}?openby:yohobuy={"url":"${data.url}","islogin":"N"}}`;
} else {
data.url = `//m.yohobuy.com/guang/${data.id}.html?openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${data.id}"},"shareparam":{"id":"${data.id}"},"share":"/guang/api/v1/share/guang","id":${data.id},"type":1,"url":"http://m.yohobuy.com/guang/${data.id}.html","islogin":"N"}}`;
}
} else {
if (data.url.indexOf('guang.m.yohobuy.com') < 0) {
data.url = data.url;
} else {
data.url = `//m.yohobuy.com/guang/${data.id}.html`;
}
}
list.push({
id: data.id,
url: isApp ? `${helpers.https(data.url)}&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${data.id}"},"shareparam":{"id":"${data.id}"},"share":"/guang/api/v1/share/guang","id":${data.id},"type":1,"url":"http:${helpers.urlFormat('/info/index', null, 'guang')}","islogin":"N"}}` : data.url, // eslint-disable-line
url: data.url,
title: data.title,
text: data.intro,
img: helpers.image(data.src, 640, 640),
... ...
... ... @@ -53,9 +53,9 @@ router.post('/opt/collectArticle', opt.collectArticle); // 资讯文章收藏 (H
router.post('/opt/favoriteBrand', opt.favoriteBrand); // 品牌收藏
router.get('/info/index', rewrite.channel, detail.indexRedirect); // 逛详情页
router.get(/^\/info\/(.*?)\.html/, rewrite.resolve, mip, detail.index); // 逛详情页 SEO优化
router.get(/^\/info\/(.*?)\.html/, rewrite.resolve, mip, detail.indexRedirect); // 逛详情页 SEO优化
router.get('/:id.html', detail.index); // 逛详情页(兼容 PC 跳转过来的链接)
router.get('/:id.html', mip, detail.index); // 逛详情页(兼容 PC 跳转过来的链接)
router.get('/info/mini', detail.mini); // 逛mini内容页
router.get('/info/foryoho', detail.foryoho); // 逛foryoho内容页
... ...
... ... @@ -16,5 +16,6 @@ const guang = require(`${cRoot}/guang`);
router.use(mip);
router.get(/^\/guang\/info\/(.*?)\.html/, rewrite.resolve, guang.detailIndex);
router.get(/^\/guang\/(.*?)\.html/, rewrite.resolve, guang.detailIndex);
module.exports = router;
... ...
... ... @@ -129,7 +129,7 @@
<div class="related-info">
{{# relatedInfo}}
<div class="info-item">
<a data-type="mip" data-title="{{title}}" href="//m.yohobuy.com/mip/guang/info/{{id}}.html">
<a data-type="mip" data-title="{{title}}" href="//m.yohobuy.com/mip/guang/{{id}}.html">
<div class="pic">
<mip-img class="pic-mip" width="117" height="73" src="{{thumb}}">
</mip-img>
... ...
... ... @@ -95,13 +95,13 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, top) => {
if (articleData.url.indexOf('guang.m.yohobuy.com') < 0) {
result.url = `${helpers.https(articleData.url)}?openby:yohobuy={"url":"${articleData.url}","islogin":"N"}}`;
} else {
result.url = `//m.yohobuy.com/guang/info/${articleData.id}.html?openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${articleData.id}"},"shareparam":{"id":"${articleData.id}"},"share":"/guang/api/v1/share/guang","id":${articleData.id},"type":1,"url":"http://m.yohobuy.com/guang/info/${articleData.id}.html","islogin":"N"}}`;
result.url = `//m.yohobuy.com/guang/${articleData.id}.html?openby:yohobuy={"action":"go.h5","params":{"param":{"id":"${articleData.id}"},"shareparam":{"id":"${articleData.id}"},"share":"/guang/api/v1/share/guang","id":${articleData.id},"type":1,"url":"http://m.yohobuy.com/guang/${articleData.id}.html","islogin":"N"}}`;
}
} else {
if (articleData.url.indexOf('guang.m.yohobuy.com') < 0) {
result.url = articleData.url;
} else {
result.url = `//m.yohobuy.com/guang/info/${articleData.id}.html`;
result.url = `//m.yohobuy.com/guang/${articleData.id}.html`;
}
}
... ...