mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 07:12:51 +08:00
feat: 增加对Sketch 正式版的RSS 支持 (#3109)
This commit is contained in:
@@ -128,6 +128,10 @@ pageClass: routes
|
||||
|
||||
<Route author="Jeason0228" example="/sketch/beta" path="/sketch/beta" />
|
||||
|
||||
### Release 更新
|
||||
|
||||
<Route author="Jeason0228" example="/sketch/updates" path="/sketch/updates" />
|
||||
|
||||
## Thunderbird
|
||||
|
||||
### 更新日志
|
||||
|
||||
@@ -1111,8 +1111,11 @@ router.get('/nowcoder/discuss/:type/:order', require('./routes/nowcoder/discuss'
|
||||
|
||||
// Xiaomi.eu
|
||||
router.get('/xiaomieu/releases', require('./routes/xiaomieu/releases'));
|
||||
|
||||
// sketch.com
|
||||
router.get('/sketch/beta', require('./routes/sketch/beta'));
|
||||
router.get('/sketch/updates', require('./routes/sketch/updates'));
|
||||
|
||||
// 每日安全
|
||||
router.get('/security/pulses', require('./routes/security/pulses'));
|
||||
|
||||
|
||||
56
lib/routes/sketch/updates.js
Normal file
56
lib/routes/sketch/updates.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: 'https://cdn.sketchapp.com/releases.html',
|
||||
});
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
const list = $('div.update');
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Sketch Release版本',
|
||||
link: response.url,
|
||||
description: $('meta[name="description"]').attr('content'),
|
||||
image: 'https://cdn.sketchapp.com/assets/components/block-buy/logo.png',
|
||||
|
||||
item:
|
||||
list &&
|
||||
list
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
// sketch update 提供的时间 年月反了.要重新调整
|
||||
const pubday = item
|
||||
.find('section.update-highlights time')
|
||||
.attr('datetime')
|
||||
.substr(0, 2);
|
||||
const pubmonth = item
|
||||
.find('section.update-highlights time')
|
||||
.attr('datetime')
|
||||
.substr(3, 2);
|
||||
const pubyear = item
|
||||
.find('section.update-highlights time')
|
||||
.attr('datetime')
|
||||
.substr(-4);
|
||||
const pubdateString = pubmonth + `-` + pubday + `-` + pubyear;
|
||||
|
||||
return {
|
||||
title: `${item
|
||||
.find('h2.update-version-title')
|
||||
.first()
|
||||
.text()}`,
|
||||
description: `<img class="sketch-logo" src="https://cdn.sketchapp.com/assets/components/block-buy/logo.png"
|
||||
srcset="https://cdn.sketchapp.com/assets/components/block-buy/logo.png 1x, https://cdn.sketchapp.com/assets/components/block-buy/logo@2x.png 2x"
|
||||
alt="Sketch Logo">${item.find('section.update-highlights .lead').html()}<br>
|
||||
${item.find('section.update-highlights footer').html()}<br>
|
||||
${item.find('aside.update-details .mask').html()}`,
|
||||
link: `https://www.sketch.com/updates/${item.find('.update-version-title a').attr('href')}`,
|
||||
pubDate: new Date(pubdateString).toLocaleDateString(),
|
||||
};
|
||||
})
|
||||
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user