mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 04:11:26 +08:00
feat(route): add Node.js News (#8902)
This commit is contained in:
@@ -133,7 +133,6 @@ For instance, the `/github/topics/framework/l=php&o=desc&s=stars` route will gen
|
|||||||
|
|
||||||
<RouteEn author="zoenglinghou" example="/gitlab/tag/rluna-open-source%2Ffile-management%2Fowncloud/core/gitlab.com" path="/gitlab/tag/:namespace/:project/:host?" :paramsDesc="['owner or namespace. `/` needs to be replaced with `%2F`', 'project name', 'Gitlab instance hostname, default to gitlab.com']" />
|
<RouteEn author="zoenglinghou" example="/gitlab/tag/rluna-open-source%2Ffile-management%2Fowncloud/core/gitlab.com" path="/gitlab/tag/:namespace/:project/:host?" :paramsDesc="['owner or namespace. `/` needs to be replaced with `%2F`', 'project name', 'Gitlab instance hostname, default to gitlab.com']" />
|
||||||
|
|
||||||
|
|
||||||
## Hacker News
|
## Hacker News
|
||||||
|
|
||||||
### Section
|
### Section
|
||||||
@@ -230,6 +229,30 @@ Website: https://news.ycombinator.com/
|
|||||||
|
|
||||||
</RouteEn>
|
</RouteEn>
|
||||||
|
|
||||||
|
## Node.js
|
||||||
|
|
||||||
|
### News
|
||||||
|
|
||||||
|
<RouteEn author="nczitzk" example="/nodejs/blog" path="/nodejs/blog/:language?" :paramsDesc="['Language, see below, en by default']">
|
||||||
|
|
||||||
|
| العربية | Catalan | Deutsch | Español | زبان فارسی |
|
||||||
|
| ------- | ------- | ------- | ------- | ---------- |
|
||||||
|
| ar | ca | de | es | fa |
|
||||||
|
|
||||||
|
| Français | Galego | Italiano | 日本語 | 한국어 |
|
||||||
|
| -------- | ------ | -------- | ------ | ------ |
|
||||||
|
| fr | gl | it | ja | ko |
|
||||||
|
|
||||||
|
| Português do Brasil | limba română | Русский | Türkçe | Українська |
|
||||||
|
| ------------------- | ------------ | ------- | ------ | ---------- |
|
||||||
|
| pt-br | ro | ru | tr | uk |
|
||||||
|
|
||||||
|
| 简体中文 | 繁體中文 |
|
||||||
|
| -------- | -------- |
|
||||||
|
| zh-cn | zh-tw |
|
||||||
|
|
||||||
|
</RouteEn>
|
||||||
|
|
||||||
## project-zero issues
|
## project-zero issues
|
||||||
|
|
||||||
### issues
|
### issues
|
||||||
|
|||||||
@@ -334,6 +334,30 @@ GitHub 官方也提供了一些 RSS:
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
## Node.js
|
||||||
|
|
||||||
|
### News
|
||||||
|
|
||||||
|
<Route author="nczitzk" example="/nodejs/blog" path="/nodejs/blog/:language?" :paramsDesc="['语言,见下表,默认为 en']">
|
||||||
|
|
||||||
|
| العربية | Catalan | Deutsch | Español | زبان فارسی |
|
||||||
|
| ------- | ------- | ------- | ------- | ---------- |
|
||||||
|
| ar | ca | de | es | fa |
|
||||||
|
|
||||||
|
| Français | Galego | Italiano | 日本語 | 한국어 |
|
||||||
|
| -------- | ------ | -------- | ------ | ------ |
|
||||||
|
| fr | gl | it | ja | ko |
|
||||||
|
|
||||||
|
| Português do Brasil | limba română | Русский | Türkçe | Українська |
|
||||||
|
| ------------------- | ------------ | ------- | ------ | ---------- |
|
||||||
|
| pt-br | ro | ru | tr | uk |
|
||||||
|
|
||||||
|
| 简体中文 | 繁體中文 |
|
||||||
|
| -------- | -------- |
|
||||||
|
| zh-cn | zh-tw |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## NOSEC.org
|
## NOSEC.org
|
||||||
|
|
||||||
### Posts
|
### Posts
|
||||||
|
|||||||
60
lib/v2/nodejs/blog.js
Normal file
60
lib/v2/nodejs/blog.js
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const language = ctx.params.language ?? 'en';
|
||||||
|
|
||||||
|
const rootUrl = 'https://nodejs.org';
|
||||||
|
const currentUrl = `${rootUrl}/${language}/blog`;
|
||||||
|
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: currentUrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
$('.summary').remove();
|
||||||
|
|
||||||
|
let items = $('ul.blog-index li a')
|
||||||
|
.toArray()
|
||||||
|
.map((item) => {
|
||||||
|
item = $(item);
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: item.text(),
|
||||||
|
link: `${rootUrl}${item.attr('href')}`,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
items = await Promise.all(
|
||||||
|
items.map((item) =>
|
||||||
|
ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const detailResponse = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: item.link,
|
||||||
|
});
|
||||||
|
|
||||||
|
const content = cheerio.load(detailResponse.data);
|
||||||
|
|
||||||
|
item.pubDate = parseDate(content('time').attr('datetime'));
|
||||||
|
item.author = content('.blogpost-meta')
|
||||||
|
.text()
|
||||||
|
.match(/by (.*), /)[1];
|
||||||
|
|
||||||
|
content('.blogpost-header').remove();
|
||||||
|
|
||||||
|
item.description = content('article').html();
|
||||||
|
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: 'News - Node.js',
|
||||||
|
link: currentUrl,
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
3
lib/v2/nodejs/maintainer.js
Normal file
3
lib/v2/nodejs/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/blog/:language?': ['nczitzk'],
|
||||||
|
};
|
||||||
13
lib/v2/nodejs/radar.js
Normal file
13
lib/v2/nodejs/radar.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module.exports = {
|
||||||
|
'nodejs.org': {
|
||||||
|
_name: 'Node.js',
|
||||||
|
'.': [
|
||||||
|
{
|
||||||
|
title: 'News',
|
||||||
|
docs: 'https://docs.rsshub.app/programming.html#nodejs-news',
|
||||||
|
source: ['/:language/blog', '/'],
|
||||||
|
target: '/nodejs/blog/:language?',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
3
lib/v2/nodejs/router.js
Normal file
3
lib/v2/nodejs/router.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = function (router) {
|
||||||
|
router.get('/blog/:language?', require('./blog'));
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user