feat: add total commander what's new (#6325)

This commit is contained in:
Ethan Shen 2020-12-04 23:55:51 +08:00 committed by GitHub
parent 052652f2f4
commit 2aad468472
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 0 deletions

View File

@ -92,6 +92,12 @@ The owner of the official image fills in the library, for example: https://rsshu
<RouteEn author="DIYgod" example="/firefox/addons/rsshub-radar" path="/firefox/addons/:id" :paramsDesc="['Add-ons id, can be found in add-ons url']"/>
## Total Commander
### What's New
<RouteEn author="nczitzk" example="/totalcommander/whatsnew" path="/totalcommander/whatsnew"/>
## Greasy Fork
### Script Update

View File

@ -266,6 +266,12 @@ pageClass: routes
<Route author="garywill" example="/thunderbird/release" path="/thunderbird/release"/>
## Total Commander
### What's New
<Route author="nczitzk" example="/totalcommander/whatsnew" path="/totalcommander/whatsnew"/>
## Typora
### Changelog

View File

@ -3517,6 +3517,9 @@ router.get('/uisdc/news', require('./routes/uisdc/news'));
router.get('/uisdc/zt/:title?', require('./routes/uisdc/zt'));
router.get('/uisdc/topic/:title?/:sort?', require('./routes/uisdc/topic'));
// Total Commander
router.get('/totalcommander/whatsnew', require('./routes/totalcommander/whatsnew'));
// Blizzard
router.get('/blizzard/news/:language?/:category?', require('./routes/blizzard/news'));

View File

@ -0,0 +1,32 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const date = require('@/utils/date');
module.exports = async (ctx) => {
const rootUrl = 'http://ghisler.com';
const currentUrl = `${rootUrl}/whatsnew.htm`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data.replace(/<h3 align="left">/g, '</content><content><h3 align="left">'));
const items = $('content')
.map((_, item) => {
item = $(item);
return {
link: currentUrl,
title: item.find('h3').text(),
description: item.find('p').html(),
pubDate: date(item.find('b').text().split(':')[0]),
};
})
.get();
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};