diff --git a/docs/en/shopping.md b/docs/en/shopping.md index 248a787ba..560f015f1 100644 --- a/docs/en/shopping.md +++ b/docs/en/shopping.md @@ -36,6 +36,32 @@ Parameter `time` only works when `mostwanted` is chosen as the category. +## Arcteryx + +### New Arrivals + + + +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. + +::: + + + ## Bellroy ### New Releases diff --git a/docs/shopping.md b/docs/shopping.md index 2cb24e10d..2f6ed7c47 100644 --- a/docs/shopping.md +++ b/docs/shopping.md @@ -48,6 +48,32 @@ pageClass: routes +## Arcteryx + +### 新发布 + + + +国家 + +| 美国 | 加拿大 | 英国 | +| -- | --- | -- | +| us | ca | gb | + +性别 + +| 男 | 女 | +| ---- | ------ | +| mens | womens | + +::: tip 提示 + +参数 `country` 可以在 `Arcteryx` 官网的 URL 中找到。 + +::: + + + ## Bellroy ### 新发布 diff --git a/lib/v2/arcteryx/maintainer.js b/lib/v2/arcteryx/maintainer.js new file mode 100644 index 000000000..0590f9a2c --- /dev/null +++ b/lib/v2/arcteryx/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/new-arrivals/:country/:gender': ['NavePnow'], +}; diff --git a/lib/v2/arcteryx/new-arrivals.js b/lib/v2/arcteryx/new-arrivals.js new file mode 100644 index 000000000..5ff99117d --- /dev/null +++ b/lib/v2/arcteryx/new-arrivals.js @@ -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, + }), + })), + }; +}; diff --git a/lib/v2/arcteryx/radar.js b/lib/v2/arcteryx/radar.js new file mode 100644 index 000000000..c5dda380f --- /dev/null +++ b/lib/v2/arcteryx/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/arcteryx/router.js b/lib/v2/arcteryx/router.js new file mode 100644 index 000000000..b14dd68cd --- /dev/null +++ b/lib/v2/arcteryx/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/new-arrivals/:country/:gender', require('./new-arrivals')); +}; diff --git a/lib/v2/arcteryx/templates/product-description.art b/lib/v2/arcteryx/templates/product-description.art new file mode 100644 index 000000000..1f7d0e26d --- /dev/null +++ b/lib/v2/arcteryx/templates/product-description.art @@ -0,0 +1,6 @@ +
+ +

+ {{item.short_description}} +

+