diff --git a/docs/blog.md b/docs/blog.md index 631ddf2d73..e3b91e4650 100644 --- a/docs/blog.md +++ b/docs/blog.md @@ -90,6 +90,18 @@ pageClass: routes +## PolkaWorld + +### 最新资讯 + + + +::: tip 提示 + +在路由末尾处加上 `?limit=限制获取数目` 来限制获取条目数量,默认值为`10`. + +::: + ## Whoscall ### 最新文章 diff --git a/docs/en/blog.md b/docs/en/blog.md index cf7e45e668..38145f1bc1 100644 --- a/docs/en/blog.md +++ b/docs/en/blog.md @@ -44,6 +44,17 @@ pageClass: routes ## Phrack Magazine +## PolkaWorld + +### Newest Articles + + +::: tip + +Limit the number of entries to be retrieved by adding `?limit=x` to the end of the route, default value is `10`. + +::: + ### Article diff --git a/lib/v2/polkaworld/home.js b/lib/v2/polkaworld/home.js new file mode 100644 index 0000000000..ffd6afdca7 --- /dev/null +++ b/lib/v2/polkaworld/home.js @@ -0,0 +1,24 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +module.exports = async (ctx) => { + const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 10; + const response = await got({ + method: 'get', + url: 'https://pub.polkaworld.pro/articles?_sort=PublishDate:desc&_limit=' + limit, + }); + const docList = response.data; + + ctx.state.data = { + title: 'PolkaWorld-资讯', + link: 'https://www.polkaworld.org/', + item: docList.map((item) => ({ + title: item.Title, + description: item.Title, + pubDate: timezone(parseDate(item.PublishDate), 0), + author: item.author.Name, + link: 'https://www.polkaworld.org/articles/' + item.URL, + })), + }; +}; diff --git a/lib/v2/polkaworld/maintainer.js b/lib/v2/polkaworld/maintainer.js new file mode 100644 index 0000000000..e33a028fbf --- /dev/null +++ b/lib/v2/polkaworld/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/polkaworld/newest': ['iceqing'], +}; diff --git a/lib/v2/polkaworld/radar.js b/lib/v2/polkaworld/radar.js new file mode 100644 index 0000000000..d0b2b95cb9 --- /dev/null +++ b/lib/v2/polkaworld/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'polkaworld.org': { + _name: 'PolkaWorld', + www: [ + { + title: '最新资讯', + docs: 'https://docs.rsshub.app/blog.html#polkaworld', + source: ['/', '/articles/:name'], + target: '/polkaworld/newest', + }, + ], + }, +}; diff --git a/lib/v2/polkaworld/router.js b/lib/v2/polkaworld/router.js new file mode 100644 index 0000000000..7f76f5015c --- /dev/null +++ b/lib/v2/polkaworld/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/newest', require('./home')); +};