feat(route): add TradingView Desktop releases and release notes (#14234)
This commit is contained in:
parent
9dc7e52db9
commit
376ebf4bc4
|
|
@ -0,0 +1,61 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 50;
|
||||
|
||||
const rootUrl = 'https://www.tradingview.com';
|
||||
const currentUrl = new URL('/support/solutions/43000673888-tradingview-desktop-releases-and-release-notes/', rootUrl).href;
|
||||
|
||||
const { data: response } = await got(currentUrl);
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
$('h4[data-identifyelement]').each((_, el) => {
|
||||
el = $(el);
|
||||
|
||||
if (el.text().trim() === '') {
|
||||
el.remove();
|
||||
}
|
||||
});
|
||||
|
||||
const items = $('h4[data-identifyelement]')
|
||||
.toArray()
|
||||
.slice(0, limit)
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
const title = item.text();
|
||||
const description = $.html(item.nextUntil('h4'));
|
||||
const content = cheerio.load(description);
|
||||
|
||||
return {
|
||||
title,
|
||||
link: currentUrl,
|
||||
description,
|
||||
category: content('h5')
|
||||
.toArray()
|
||||
.map((c) => $(c).text()),
|
||||
guid: `tradingview-desktop#${title.split(/versions?\s/).pop()}`,
|
||||
pubDate: timezone(parseDate(title.split(/\./)[0], 'MMMM D, YYYY'), +8),
|
||||
};
|
||||
});
|
||||
|
||||
const title = $('title').text();
|
||||
const titleSplits = title.split(/—/);
|
||||
const icon = new URL($('link[rel="icon"]').prop('href'), rootUrl).href;
|
||||
|
||||
ctx.state.data = {
|
||||
item: items,
|
||||
title,
|
||||
link: currentUrl,
|
||||
description: titleSplits[0],
|
||||
language: $('html').prop('lang'),
|
||||
icon,
|
||||
logo: icon,
|
||||
subtitle: titleSplits[0],
|
||||
author: titleSplits.pop(),
|
||||
};
|
||||
};
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
module.exports = {
|
||||
'/blog/:language?/category/:category?': ['nczitzk'],
|
||||
'/desktop': ['nczitzk'],
|
||||
};
|
||||
|
|
|
|||
|
|
@ -92,6 +92,12 @@ module.exports = {
|
|||
source: ['/blog/:language/category/widgets/'],
|
||||
target: '/tradingview/blog/:language/category/widgets',
|
||||
},
|
||||
{
|
||||
title: 'Desktop releases and release notes',
|
||||
docs: 'https://docs.rsshub.app/routes/program-update#tradingview-desktop-releases-and-release-notes',
|
||||
source: ['/support/solutions/43000673888-tradingview-desktop-releases-and-release-notes/'],
|
||||
target: '/tradingview/desktop',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/blog/:category*', require('./blog'));
|
||||
router.get('/desktop', require('./desktop'));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -616,6 +616,10 @@ Logseq 开发团队已经放弃了 [旧网站](https://logseq.com/blog)。
|
|||
| [Widgets](https://www.tradingview.com/blog/en/category/widgets/) | category/widgets |
|
||||
</Route>
|
||||
|
||||
### Desktop releases and release notes {#tradingview-desktop-releases-and-release-notes}
|
||||
|
||||
<Route author="nczitzk" example="/tradingview/desktop" path="/tradingview/desktop" radar="1" />
|
||||
|
||||
## Typora {#typora}
|
||||
|
||||
### Changelog {#typora-changelog}
|
||||
|
|
|
|||
Loading…
Reference in New Issue