forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): snow-peak new arrivals (DIYgod#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
- Loading branch information
1 parent
62da7bf
commit e287440
Showing
7 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/us/new-arrivals': ['NavePnow'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function (router) { | ||
router.get('/us/new-arrivals', require('./us-new-arrivals')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<div> | ||
Variant: | ||
<br> | ||
{{each product.variants}} | ||
{{$value.name}} | ||
<br> | ||
{{/each}} | ||
{{each product.images}} | ||
<img src={{$value}}> | ||
{{/each}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
})), | ||
}; | ||
}; |