diff --git a/docs/blog.md b/docs/blog.md index 6231c82ae..3aabb6946 100644 --- a/docs/blog.md +++ b/docs/blog.md @@ -278,6 +278,18 @@ username 为博主用户名,而非`xxx.hashnode.dev`中`xxx`所代表的 blog +## 零博客 + +### 分类 + + + +| muitinⒾ | aidemnⒾ | srettaⓂ | qⓅ | sucoⓋ | +| ------- | ------- | ------- | -- | ----- | +| initium | inmedia | matters | pq | vocus | + + + ## 每日安全 ### 推送 diff --git a/lib/v2/agora0/index.js b/lib/v2/agora0/index.js new file mode 100644 index 000000000..4ebeffcf1 --- /dev/null +++ b/lib/v2/agora0/index.js @@ -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, + }; +}; diff --git a/lib/v2/agora0/maintainer.js b/lib/v2/agora0/maintainer.js new file mode 100644 index 000000000..81eb78d73 --- /dev/null +++ b/lib/v2/agora0/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:category?': ['nczitzk'], +}; diff --git a/lib/v2/agora0/radar.js b/lib/v2/agora0/radar.js new file mode 100644 index 000000000..02b3dfdea --- /dev/null +++ b/lib/v2/agora0/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/agora0/router.js b/lib/v2/agora0/router.js new file mode 100644 index 000000000..cf781366f --- /dev/null +++ b/lib/v2/agora0/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:category?', require('./index')); +};