feat: add anytxt release notes

This commit is contained in:
nczitzk 2020-12-30 08:02:57 +08:00
parent b1ae777b87
commit d27fc7c73c
4 changed files with 48 additions and 0 deletions

View File

@ -10,6 +10,12 @@ pageClass: routes
<Route author="nczitzk" example="/anki/changes" path="/anki/changes"/>
## AnyTXT
### Release Notes
<Route author="nczitzk" example="/anytxt/release-notes" path="/anytxt/release-notes"/>
## Apkpure
### Versions

View File

@ -20,6 +20,12 @@ pageClass: routes
<Route author="nczitzk" example="/anki/changes" path="/anki/changes"/>
## AnyTXT
### Release Notes
<Route author="nczitzk" example="/anytxt/release-notes" path="/anytxt/release-notes"/>
## Apkpure
### Versions

View File

@ -3780,4 +3780,7 @@ router.get('/nace/blog/:sort?', require('./routes/nace/blog'));
// Caixin Latest
router.get('/caixin/latest', require('./routes/caixin/latest'));
// AnyTXT
router.get('/anytxt/release-notes', require('./routes/anytxt/release-notes'));
module.exports = router;

View File

@ -0,0 +1,33 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const rootUrl = 'https://anytxt.net';
const currentUrl = `${rootUrl}/download`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const items = $('.has-medium-font-size')
.map((_, item) => {
item = $(item);
const date = item.text().replace(':', '');
return {
title: date,
link: currentUrl,
pubDate: new Date(date).toUTCString(),
description: `<ol>${item.next().html()}</ol>`,
};
})
.get();
ctx.state.data = {
title: 'Release Notes - AnyTXT',
link: currentUrl,
item: items,
};
};