mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): 增加登链社区 (#11759)
* feat(route): 增加登链社区 * fix(route): 修复路由找不到的问题 * fix(route): 修复eslint问题 * fix(route): 修复deepscan报错 * Update docs/programming.md * Update lib/v2/learnblockchain/posts.js * fix(route): 修复错误日期 ---------
This commit is contained in:
@@ -824,6 +824,35 @@ GitHub 官方也提供了一些 RSS:
|
||||
|
||||
<Route author="phantomk" example="/eleme/open-be/announce" path="/eleme/open-be/announce"/>
|
||||
|
||||
## 登链社区
|
||||
|
||||
### 文章
|
||||
|
||||
<Route author="running-grass" example="/learnblockchain/posts/DApp/newest" path="/eleduck/posts/:cid/:sort?" :paramsDesc="['分类id,更多分类可以论坛的URL找到', '排序方式,默认精选']" radar="1">
|
||||
|
||||
| id | 分类 |
|
||||
|----------|--------------|
|
||||
| all | 全部 |
|
||||
| DApp | 去中心化应用 |
|
||||
| chains | 公链 |
|
||||
| 联盟链 | 联盟链 |
|
||||
| scaling | Layer2 |
|
||||
| langs | 编程语言 |
|
||||
| security | 安全 |
|
||||
| dst | 存储 |
|
||||
| basic | 理论研究 |
|
||||
| other | 其他 |
|
||||
|
||||
|
||||
| id | 排序方式 |
|
||||
|----------|------------|
|
||||
| newest | 最新 |
|
||||
| featured | 精选(默认) |
|
||||
| featured | 最赞 |
|
||||
| hottest | 最热 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 极客时间
|
||||
|
||||
### 专栏文章
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/posts/:cid/:sort?': ['running-grass'],
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
const {
|
||||
parseRelativeDate
|
||||
} = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const cid = ctx.params.cid || 'all';
|
||||
const sort = ctx.params.sort;
|
||||
|
||||
let url = 'https://learnblockchain.cn/categories/';
|
||||
url += cid + '/';
|
||||
|
||||
if (sort) {
|
||||
url += sort + '/';
|
||||
}
|
||||
|
||||
const response = await got(url);
|
||||
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
const list = $('div.stream-list section.stream-list-item');
|
||||
|
||||
ctx.state.data = {
|
||||
title: `登链社区--${cid}`,
|
||||
link: url,
|
||||
description: `登链社区`,
|
||||
item: list && list.map((idx, ite) => {
|
||||
const item = $(ite);
|
||||
const json = {
|
||||
title: item.find('h2.title').text().trim(),
|
||||
description: item.find('div.excerpt').text().trim(),
|
||||
pubDate: parseRelativeDate(item.find('.author li:nth-child(2)').text().replace('发布于', '').trim()),
|
||||
link: item.find('h2.title a').attr('href').trim(),
|
||||
author: item.find('.author li:nth-child(1)').text().trim(),
|
||||
};
|
||||
|
||||
return json;
|
||||
}).get(),
|
||||
};
|
||||
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
module.exports = {
|
||||
'learnblockchain.cn': {
|
||||
_name: '登链社区',
|
||||
'.': [{
|
||||
title: '分类文章',
|
||||
docs: 'https://docs.rsshub.app/programming.html#deng-lian-she-qu-wen-zhang',
|
||||
source: '/categories/:cid/:sort?',
|
||||
target: (params) => `/learnblockchain/posts/${params.cid}/${params.sort}`,
|
||||
},
|
||||
{
|
||||
title: '全部文章',
|
||||
docs: 'https://docs.rsshub.app/programming.html#deng-lian-she-qu-wen-zhang',
|
||||
source: '*',
|
||||
target: () => '/learnblockchain/posts/all/',
|
||||
}
|
||||
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/posts/:cid/:sort?', require('./posts'));
|
||||
};
|
||||
Reference in New Issue
Block a user