Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
周少峰
8 years ago
Commit
bc03f2cae9581d3f31bd7405bd60bf84a54a9f62
1 parent
52e4e61c
301, page url
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
146 deletions
apps/3party/controllers/sitemap.js
apps/guang/models/guang-service.js
apps/guang/models/url-helper.js
config/staticUrls.js
doraemon/middleware/htaccess/rules/guang.js
apps/3party/controllers/sitemap.js
View file @
bc03f2c
...
...
@@ -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
))
{
...
...
apps/guang/models/guang-service.js
View file @
bc03f2c
...
...
@@ -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
)
};
});
});
...
...
apps/guang/models/url-helper.js
View file @
bc03f2c
...
...
@@ -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
)
;
};
...
...
config/staticUrls.js
View file @
bc03f2c
...
...
@@ -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
:
[],
...
...
doraemon/middleware/htaccess/rules/guang.js
View file @
bc03f2c
...
...
@@ -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
);
}
}
];
...
...
Please
register
or
login
to post a comment