feat(route): Arcteryx new arrivals (#12040)
* feat: new route for arcteryx * fix: radar source ---------
This commit is contained in:
parent
7035c394ec
commit
94986690f0
|
|
@ -36,6 +36,32 @@ Parameter `time` only works when `mostwanted` is chosen as the category.
|
|||
|
||||
</RouteEn>
|
||||
|
||||
## Arcteryx
|
||||
|
||||
### New Arrivals
|
||||
|
||||
<RouteEn author="NavePnow" example="/arcteryx/new-arrivals/us/mens" path="/arcteryx/new-arrivals/: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>
|
||||
|
||||
## Bellroy
|
||||
|
||||
### New Releases
|
||||
|
|
|
|||
|
|
@ -48,6 +48,32 @@ pageClass: routes
|
|||
|
||||
</Route>
|
||||
|
||||
## Arcteryx
|
||||
|
||||
### 新发布
|
||||
|
||||
<Route author="NavePnow" example="/arcteryx/new-arrivals/us/mens" path="/arcteryx/new-arrivals/:country/:gender" :paramsDesc="['国家', '性别']">
|
||||
|
||||
国家
|
||||
|
||||
| 美国 | 加拿大 | 英国 |
|
||||
| -- | --- | -- |
|
||||
| us | ca | gb |
|
||||
|
||||
性别
|
||||
|
||||
| 男 | 女 |
|
||||
| ---- | ------ |
|
||||
| mens | womens |
|
||||
|
||||
::: tip 提示
|
||||
|
||||
参数 `country` 可以在 `Arcteryx` 官网的 URL 中找到。
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
## Bellroy
|
||||
|
||||
### 新发布
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/new-arrivals/:country/:gender': ['NavePnow'],
|
||||
};
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
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://arcteryx.com/${country}/en/`;
|
||||
const url = `${host}api/fredhopper/query`;
|
||||
const productUrl = `${host}shop/`;
|
||||
const pageUrl = `${host}c/${gender}/new-arrivals`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
searchParams: {
|
||||
fh_location: `//catalog01/en_CA/gender>{${gender}}/intended_use>{newarrivals}`,
|
||||
fh_country: country,
|
||||
fh_view_size: 'all',
|
||||
},
|
||||
});
|
||||
const items = response.data.universes.universe[1]['items-section'].items.item;
|
||||
items.forEach(generateRssData);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Arcteryx - New Arrivals(${country.toUpperCase()}) - ${gender.toUpperCase()}`,
|
||||
link: pageUrl,
|
||||
description: `Arcteryx - New Arrivals(${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,
|
||||
}),
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'arcteryx.com': {
|
||||
_name: 'Arcteryx',
|
||||
'.': [
|
||||
{
|
||||
title: '新发布',
|
||||
docs: 'https://docs.rsshub.app/shopping.html#arcteryx',
|
||||
source: ['/:country/en/c/:gender/new-arrivals'],
|
||||
target: '/arcteryx/new-arrivals/:country/:gender',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/new-arrivals/:country/:gender', require('./new-arrivals'));
|
||||
};
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<div>
|
||||
<img src={{item.image}}>
|
||||
<br><br>
|
||||
{{item.short_description}}
|
||||
<br><br>
|
||||
</div>
|
||||
Loading…
Reference in New Issue