mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-02 10:08:02 +08:00
feat(route): add 零博客 (#10035)
This commit is contained in:
12
docs/blog.md
12
docs/blog.md
@@ -278,6 +278,18 @@ username 为博主用户名,而非`xxx.hashnode.dev`中`xxx`所代表的 blog
|
||||
|
||||
<Route author="a180285" example="/blogs/jingwei.link" path="/blogs/jingwei.link"/>
|
||||
|
||||
## 零博客
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="nczitzk" example="/agora0/initium" path="/agora0/:category?" :paramsDesc="['分类,见下表,默认为 initium,即端传媒']">
|
||||
|
||||
| muitinⒾ | aidemnⒾ | srettaⓂ | qⓅ | sucoⓋ |
|
||||
| ------- | ------- | ------- | -- | ----- |
|
||||
| initium | inmedia | matters | pq | vocus |
|
||||
|
||||
</Route>
|
||||
|
||||
## 每日安全
|
||||
|
||||
### 推送
|
||||
|
||||
54
lib/v2/agora0/index.js
Normal file
54
lib/v2/agora0/index.js
Normal file
@@ -0,0 +1,54 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? 'initium';
|
||||
|
||||
const rootUrl = 'https://agora0.gitlab.io';
|
||||
const currentUrl = `${rootUrl}/blog/${category}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
let items = $('.card span:not(.comments) a')
|
||||
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 50)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: 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.author = content('meta[name="author"]').attr('content');
|
||||
item.pubDate = parseDate(content('meta[property="article:published_time"]').attr('content'));
|
||||
item.description = content('.post-content').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
3
lib/v2/agora0/maintainer.js
Normal file
3
lib/v2/agora0/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/:category?': ['nczitzk'],
|
||||
};
|
||||
13
lib/v2/agora0/radar.js
Normal file
13
lib/v2/agora0/radar.js
Normal file
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'gitlab.io': {
|
||||
_name: 'GitLab',
|
||||
agora0: [
|
||||
{
|
||||
title: '零博客',
|
||||
docs: 'https://docs.rsshub.app/blog.html#ling-bo-ke-fen-lei',
|
||||
source: ['/blog/:category', '/'],
|
||||
target: '/agora0/:category',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
3
lib/v2/agora0/router.js
Normal file
3
lib/v2/agora0/router.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/:category?', require('./index'));
|
||||
};
|
||||
Reference in New Issue
Block a user