diff --git a/docs/en/social-media.md b/docs/en/social-media.md index ea83ae4718..75ecd27167 100644 --- a/docs/en/social-media.md +++ b/docs/en/social-media.md @@ -4,6 +4,12 @@ pageClass: routes # Social Media +## Bluesky (bsky) + +### Keywords + + + ## Crossbell ### Notes diff --git a/docs/social-media.md b/docs/social-media.md index 308cb5eb88..b1aff0100a 100644 --- a/docs/social-media.md +++ b/docs/social-media.md @@ -24,6 +24,12 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性 ::: +## Bluesky (bsky) + +### 关键词 + + + ### 番剧 diff --git a/lib/v2/bsky/keyword.js b/lib/v2/bsky/keyword.js new file mode 100644 index 0000000000..7c1b04bfaa --- /dev/null +++ b/lib/v2/bsky/keyword.js @@ -0,0 +1,22 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const { keyword } = ctx.params; + const apiLink = `https://search.bsky.social/search/posts?q=${encodeURIComponent(keyword)}`; + + const { data } = await got(apiLink); + + const items = data.map((item) => ({ + title: item.post.text, + link: `https://bsky.app/profile/${item.user.handle}/post/${item.tid.split('/')[1]}`, + description: item.post.text, + pubDate: new Date(item.post.createdAt / 1000000), + author: item.user.handle, + })); + + ctx.state.data = { + title: `Bluesky Keyword - ${keyword}`, + link: `https://bsky.app/search?q=${encodeURIComponent(keyword)}`, + item: items, + }; +}; diff --git a/lib/v2/bsky/maintainer.js b/lib/v2/bsky/maintainer.js new file mode 100644 index 0000000000..61f792cbb4 --- /dev/null +++ b/lib/v2/bsky/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/keyword/:keyword': ['untitaker'], +}; diff --git a/lib/v2/bsky/radar.js b/lib/v2/bsky/radar.js new file mode 100644 index 0000000000..d0ec0e60b3 --- /dev/null +++ b/lib/v2/bsky/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'bsky.app': { + _name: 'Bluesky', + '.': [ + { + title: '关键词', + docs: 'https://docs.rsshub.app/social-media.html#bluesky-bsky', + source: '/search', + target: (params, url) => `/bsky/keyword/${new URL(url).searchParams.get('q')}`, + }, + ], + }, +}; diff --git a/lib/v2/bsky/router.js b/lib/v2/bsky/router.js new file mode 100644 index 0000000000..3d4d1c62da --- /dev/null +++ b/lib/v2/bsky/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/keyword/:keyword', require('./keyword')); +};