feat(arcteryx/outlet): add new route (#12303)
This commit is contained in:
parent
0d60360cdd
commit
1acb7e1bf5
|
|
@ -62,6 +62,30 @@ Parameter `country` can be found within the url of `Arcteryx` website.
|
|||
|
||||
</RouteEn>
|
||||
|
||||
### Outlet
|
||||
|
||||
<RouteEn author="NavePnow" example="/arcteryx/outlet/us/mens" path="/arcteryx/outlet/:country/:gender" :paramsDesc="['country', 'gender']">
|
||||
|
||||
Country
|
||||
|
||||
| United States | Canada | United Kingdom |
|
||||
| ------------- | ------ | -------------- |
|
||||
| us | ca | gb |
|
||||
|
||||
gender
|
||||
|
||||
| male | female |
|
||||
| ---- | ------ |
|
||||
| mens | womens |
|
||||
|
||||
::: tip
|
||||
|
||||
Parameter `country` can be found within the url of `Arcteryx` website.
|
||||
|
||||
:::
|
||||
|
||||
</RouteEn>
|
||||
|
||||
### Regear New Arrivals
|
||||
|
||||
<RouteEn author="NavePnow" example="/arcteryx/regear/new-arrivals" path="/arcteryx/regear/new-arrivals" />
|
||||
|
|
|
|||
|
|
@ -74,6 +74,30 @@ pageClass: routes
|
|||
|
||||
</Route>
|
||||
|
||||
### Outlet
|
||||
|
||||
<Route author="NavePnow" example="/arcteryx/outlet/us/mens" path="/arcteryx/outlet/:country/:gender" :paramsDesc="['国家', '性别']">
|
||||
|
||||
国家
|
||||
|
||||
| 美国 | 加拿大 | 英国 |
|
||||
| ---- | ------ | ---- |
|
||||
| us | ca | gb |
|
||||
|
||||
性别
|
||||
|
||||
| 男 | 女 |
|
||||
| ---- | ------ |
|
||||
| mens | womens |
|
||||
|
||||
::: tip 提示
|
||||
|
||||
参数 `country` 可以在 `Arcteryx` 官网的 URL 中找到。
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
### Regear 新发布
|
||||
|
||||
<Route author="NavePnow" example="/arcteryx/regear/new-arrivals" path="/arcteryx/regear/new-arrivals" />
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
module.exports = {
|
||||
'/new-arrivals/:country/:gender': ['NavePnow'],
|
||||
'/outlet/:country/:gender': ['NavePnow'],
|
||||
'/regear/new-arrivals': ['NavePnow'],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
const got = require('@/utils/got');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
const attributeSet = new Set(['name', 'image', 'short_description', 'slug']);
|
||||
function generateRssData(item, index, arr) {
|
||||
const attributes = item.attribute;
|
||||
const data = {};
|
||||
|
||||
attributes.forEach((attribute) => {
|
||||
const key = attribute.name;
|
||||
const value = attribute.value[0].value;
|
||||
if (attributeSet.has(key)) {
|
||||
data[key] = value;
|
||||
}
|
||||
});
|
||||
arr[index] = data;
|
||||
}
|
||||
module.exports = async (ctx) => {
|
||||
const { country, gender } = ctx.params;
|
||||
const host = `https://outlet.arcteryx.com/${country}/en/`;
|
||||
const url = `${host}api/fredhopper/query`;
|
||||
const productUrl = `${host}shop/`;
|
||||
const pageUrl = `${host}c/${gender}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
searchParams: {
|
||||
fh_location: `//catalog01/en_CA/gender>{${gender}}`,
|
||||
fh_country: country,
|
||||
fh_review: 'lister',
|
||||
fh_view_size: 'all',
|
||||
fh_context_location: '//catalog01',
|
||||
},
|
||||
});
|
||||
const items = response.data.universes.universe[1]['items-section'].items.item;
|
||||
items.forEach(generateRssData);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Arcteryx - Outlet(${country.toUpperCase()}) - ${gender.toUpperCase()}`,
|
||||
link: pageUrl,
|
||||
description: `Arcteryx - Outlet(${country.toUpperCase()}) - ${gender.toUpperCase()}`,
|
||||
item: items.map((item) => ({
|
||||
title: item.name,
|
||||
link: productUrl + item.slug,
|
||||
description: art(path.join(__dirname, 'templates/product-description.art'), {
|
||||
item,
|
||||
}),
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
@ -9,6 +9,14 @@ module.exports = {
|
|||
target: '/arcteryx/new-arrivals/:country/:gender',
|
||||
},
|
||||
],
|
||||
outlet: [
|
||||
{
|
||||
title: 'Outlet',
|
||||
docs: 'https://docs.rsshub.app/shopping.html#arcteryx',
|
||||
source: ['/:country/en/c/:gender'],
|
||||
target: '/arcteryx/outlet/:country/:gender',
|
||||
},
|
||||
],
|
||||
regear: [
|
||||
{
|
||||
title: 'Regear 新发布',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/new-arrivals/:country/:gender', require('./new-arrivals'));
|
||||
router.get('/outlet/:country/:gender', require('./outlet'));
|
||||
router.get('/regear/new-arrivals', require('./regear-new-arrivals'));
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue