feat(route): snow-peak new arrivals (#12045)
* feat(route): snow-peak new arrivals * feat: change path to snowpeak/us/new-arrivals * feat: add pubData and category * feat: add variants and multiple images * fix: pubDate
This commit is contained in:
parent
62da7bf91c
commit
e287440507
|
|
@ -206,6 +206,12 @@ Language
|
|||
|
||||
<RouteEn author="nczitzk" example="/shopback/shopee-mart" path="/shopback/:store" :paramsDesc="['Store, can be found in URL']"/>
|
||||
|
||||
## Snow Peak
|
||||
|
||||
### New Arrivals(USA)
|
||||
|
||||
<RouteEn author="NavePnow" example="/snowpeak/us/new-arrivals" path="/snowpeak/us/new-arrivals"/>
|
||||
|
||||
## The Independent
|
||||
|
||||
### PS5 stock UK
|
||||
|
|
|
|||
|
|
@ -250,6 +250,12 @@ For instance, in <https://www.leboncoin.fr/recherche/?**category=10&locations=Pa
|
|||
|
||||
<Route author="nczitzk" example="/shopback/shopee-mart" path="/shopback/:store" :paramsDesc="['店铺名,可在 URL 中找到']"/>
|
||||
|
||||
## Snow Peak
|
||||
|
||||
### New Arrivals(USA)
|
||||
|
||||
<Route author="NavePnow" example="/snowpeak/us/new-arrivals" path="/snowpeak/us/new-arrivals"/>
|
||||
|
||||
## The Independent
|
||||
|
||||
### PS5 stock UK
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/us/new-arrivals': ['NavePnow'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'snowpeak.com': {
|
||||
_name: 'Snow Peak',
|
||||
'.': [
|
||||
{
|
||||
title: 'New Arrivals(USA)',
|
||||
docs: 'https://docs.rsshub.app/shopping.html#snow-peak',
|
||||
source: ['/collections/new-arrivals', '/'],
|
||||
target: '/snowpeak/us/new-arrivals',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/us/new-arrivals', require('./us-new-arrivals'));
|
||||
};
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<div>
|
||||
Variant:
|
||||
<br>
|
||||
{{each product.variants}}
|
||||
{{$value.name}}
|
||||
<br>
|
||||
{{/each}}
|
||||
{{each product.images}}
|
||||
<img src={{$value}}>
|
||||
{{/each}}
|
||||
</div>
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
const got = require('@/utils/got');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const cheerio = require('cheerio');
|
||||
const host = 'https://www.snowpeak.com';
|
||||
module.exports = async (ctx) => {
|
||||
const url = `${host}/collections/new-arrivals`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
});
|
||||
const data = response.data;
|
||||
|
||||
const $ = cheerio.load(data);
|
||||
const list = $('.element.product-tile')
|
||||
.map(function () {
|
||||
const data = {};
|
||||
const product = $(this).find('.product-data').data('product');
|
||||
data.title = product.title;
|
||||
data.link = `${host}/products/${product.handle}`;
|
||||
data.pubDate = new Date(product.published_at).toUTCString();
|
||||
data.category = product.tags;
|
||||
data.variants = product.variants.map((item) => item.name);
|
||||
data.description =
|
||||
product.description +
|
||||
art(path.join(__dirname, 'templates/new-arrivals.art'), {
|
||||
product,
|
||||
});
|
||||
|
||||
return data;
|
||||
})
|
||||
.get();
|
||||
ctx.state.data = {
|
||||
title: 'Snow Peak - New Arrivals',
|
||||
link: `${host}/new-arrivals`,
|
||||
description: 'Snow Peak - New Arrivals',
|
||||
item: list.map((item) => ({
|
||||
title: item.title,
|
||||
category: item.category,
|
||||
description: item.description,
|
||||
pubDate: item.pubDate,
|
||||
link: item.link,
|
||||
})),
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue