mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 15:21:59 +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" />
|
<Route author="Jeason0228" example="/sketch/beta" path="/sketch/beta" />
|
||||||
|
|
||||||
|
### Release 更新
|
||||||
|
|
||||||
|
<Route author="Jeason0228" example="/sketch/updates" path="/sketch/updates" />
|
||||||
|
|
||||||
## Thunderbird
|
## Thunderbird
|
||||||
|
|
||||||
### 更新日志
|
### 更新日志
|
||||||
|
|||||||
@@ -1111,8 +1111,11 @@ router.get('/nowcoder/discuss/:type/:order', require('./routes/nowcoder/discuss'
|
|||||||
|
|
||||||
// Xiaomi.eu
|
// Xiaomi.eu
|
||||||
router.get('/xiaomieu/releases', require('./routes/xiaomieu/releases'));
|
router.get('/xiaomieu/releases', require('./routes/xiaomieu/releases'));
|
||||||
|
|
||||||
// sketch.com
|
// sketch.com
|
||||||
router.get('/sketch/beta', require('./routes/sketch/beta'));
|
router.get('/sketch/beta', require('./routes/sketch/beta'));
|
||||||
|
router.get('/sketch/updates', require('./routes/sketch/updates'));
|
||||||
|
|
||||||
// 每日安全
|
// 每日安全
|
||||||
router.get('/security/pulses', require('./routes/security/pulses'));
|
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