feat(route): add WizTree What's New (#10300)

This commit is contained in:
Ethan Shen
2022-07-22 23:22:09 +00:00
committed by GitHub
parent 78db8c1183
commit e1ee46b806
6 changed files with 79 additions and 0 deletions
+6
View File
@@ -448,6 +448,12 @@ Refer to [#minecraft](/en/game.html#minecraft)
<RouteEn author="cnzgray" example="/typora/changelog" path="/typora/changelog"/>
## WizTree
### What's New
<RouteEn author="nczitzk" example="/diskanalyzer/whats-new" path="/diskanalyzer/whats-new"/>
## X410
### News
+6
View File
@@ -535,6 +535,12 @@ pageClass: routes
<Route author="nczitzk" example="/typora/changelog-dev/macOS" path="/typora/changelog-dev/:os" :paramsDesc="['操作系统类型, 可选 `macOS``Windows``Linux`,默认为 `macOS`']"/>
## WizTree
### What's New
<Route author="nczitzk" example="/diskanalyzer/whats-new" path="/diskanalyzer/whats-new"/>
## X410
### News
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/whats-new': ['nczitzk'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'diskanalyzer.com': {
_name: "What's New",
'.': [
{
title: 'Change Log',
docs: 'https://docs.rsshub.app/program-update.html#wiztree-whats-new',
source: ['/whats-new', '/'],
target: '/diskanalyzer/whats-new',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/whats-new', require('./whats-new'));
};
+48
View File
@@ -0,0 +1,48 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const rootUrl = 'https://diskanalyzer.com';
const currentUrl = `${rootUrl}/whats-new`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const items = $('.blog-content h4')
.toArray()
.map((item) => {
item = $(item);
const title = item.text();
let description = '';
item.nextUntil('h4').each(function () {
description += $(this).html();
});
if (description === '') {
item.parent()
.nextUntil('h4')
.each(function () {
description += $(this).html();
});
}
return {
title,
link: currentUrl,
description,
pubDate: parseDate(title.match(/\((.*)\)/)[1], ['D MMMM YYYY', 'D MMM YYYY']),
};
});
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};