feat(route): add Zotero (#9650)

* feat(route): add Zotero

* docs: add en docs

* docs: use chinese for cn docs
This commit is contained in:
Zhiyang Guo
2022-04-29 01:19:12 +08:00
committed by GitHub
parent f76d0428a9
commit 4f5699ba0e
6 changed files with 67 additions and 0 deletions
+6
View File
@@ -402,3 +402,9 @@ Refer to [#minecraft](/en/game.html#minecraft)
### What's New
<RouteEn author="nczitzk" example="/xyplorer/whatsnew" path="/xyplorer/whatsnew"/>
## Zotero
### Version History
<RouteEn author="jasongzy" example="/zotero/versions" path="/zotero/versions"/>
+6
View File
@@ -508,6 +508,12 @@ pageClass: routes
<Route author="nczitzk" example="/xyplorer/whatsnew" path="/xyplorer/whatsnew"/>
## Zotero
### 版本历史
<Route author="jasongzy" example="/zotero/versions" path="/zotero/versions"/>
## 怪物猎人世界
### 更新
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/versions': ['jasongzy'],
};
+13
View File
@@ -0,0 +1,13 @@
module.exports = {
'zotero.org': {
_name: 'Zotero',
'.': [
{
title: 'Version History',
docs: 'https://docs.rsshub.app/program-update.html#zotero',
source: ['/', '/support/changelog'],
target: '/zotero/versions',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/versions', require('./versions'));
};
+36
View File
@@ -0,0 +1,36 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const url = 'https://www.zotero.org/support/changelog';
const response = await got(url);
const data = response.data;
const $ = cheerio.load(data);
const list = $('h2');
ctx.state.data = {
title: 'Zotero - Version History',
link: url,
item:
list &&
list
.map((index, item) => {
item = $(item);
let date = $(item)
.text()
.match(/\((.*)\)/);
if (Array.isArray(date)) {
date = date[1];
} else {
date = null;
}
return {
title: item.text().trim(),
description: $('<div/>').append(item.nextUntil('h2').clone()).html(),
pubDate: date,
link: url + '#' + item.attr('id'),
};
})
.get(),
};
};