diff --git a/docs/blog.md b/docs/blog.md index 83fed53a6..6f20147b8 100644 --- a/docs/blog.md +++ b/docs/blog.md @@ -290,18 +290,6 @@ username 为博主用户名,而非`xxx.hashnode.dev`中`xxx`所代表的 blog -## 零博客 - -### 分类 - - - -| muitinⒾ | aidemnⒾ | srettaⓂ | qⓅ | sucoⓋ | -| ------- | ------- | ------- | -- | ----- | -| initium | inmedia | matters | pq | vocus | - - - ## 每日安全 ### 推送 diff --git a/docs/new-media.md b/docs/new-media.md index bab15d707..9acdc7d1a 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -151,6 +151,22 @@ pageClass: routes +## AG⓪RA + +### 零博客 + + + +| muitinⒾ | aidemnⒾ | srettaⓂ | qⓅ | sucoⓋ | +| ------- | ------- | ------- | -- | ----- | +| initium | inmedia | matters | pq | vocus | + + + +### 共和報 + + + ## AppleInsider ### 分类 diff --git a/lib/v2/agora0/maintainer.js b/lib/v2/agora0/maintainer.js index 81eb78d73..c3a51f404 100644 --- a/lib/v2/agora0/maintainer.js +++ b/lib/v2/agora0/maintainer.js @@ -1,3 +1,4 @@ module.exports = { + '/pen0': ['TonyRL'], '/:category?': ['nczitzk'], }; diff --git a/lib/v2/agora0/pen0.js b/lib/v2/agora0/pen0.js new file mode 100644 index 000000000..da5312e44 --- /dev/null +++ b/lib/v2/agora0/pen0.js @@ -0,0 +1,43 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const baseUrl = 'https://agorahub.github.io'; + const response = await got(`${baseUrl}/pen0/`); + const $ = cheerio.load(response.data); + + const list = $('div article') + .toArray() + .slice(0, -1) // last one is a dummy + .map((item) => { + item = $(item); + const meta = item.find('h5').first().text(); + return { + title: item.find('h3').text(), + link: item.find('h3 a').attr('href'), + author: meta.split('|')[0].trim(), + pubDate: parseDate(meta.split('|')[1].trim()), + }; + }); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const response = await got(item.link); + const $ = cheerio.load(response.data); + $('h1').remove(); + item.description = $('article').html(); + return item; + }) + ) + ); + + ctx.state.data = { + title: $('head title').text(), + description: $('head meta[name="description"]').attr('content'), + link: response.url, + image: $('link[rel="apple-touch-icon"]').attr('href'), + item: items, + }; +}; diff --git a/lib/v2/agora0/radar.js b/lib/v2/agora0/radar.js index 02b3dfdea..031864e8e 100644 --- a/lib/v2/agora0/radar.js +++ b/lib/v2/agora0/radar.js @@ -1,10 +1,21 @@ module.exports = { + 'github.io': { + _name: 'GitHub', + agorahub: [ + { + title: '共和報', + docs: 'https://docs.rsshub.app/new-media.html#ag0ra', + source: ['/pen0'], + target: '/agora0/pen0', + }, + ], + }, 'gitlab.io': { _name: 'GitLab', agora0: [ { title: '零博客', - docs: 'https://docs.rsshub.app/blog.html#ling-bo-ke-fen-lei', + docs: 'https://docs.rsshub.app/new-media.html#ag0ra', source: ['/blog/:category', '/'], target: '/agora0/:category', }, diff --git a/lib/v2/agora0/router.js b/lib/v2/agora0/router.js index cf781366f..b38dc98f6 100644 --- a/lib/v2/agora0/router.js +++ b/lib/v2/agora0/router.js @@ -1,3 +1,4 @@ module.exports = function (router) { + router.get('/pen0', require('./pen0')); router.get('/:category?', require('./index')); };