Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from diygod:master #844

Merged
merged 2 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/en/social-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ pageClass: routes

# Social Media

## Bluesky (bsky)

### Keywords

<RouteEn author="untitaker" example="/bsky/keyword/hello" path="/bsky/keyword/:keyword" radar="1" rssbud="1" />

## Crossbell

### Notes
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@vuepress/plugin-pwa": "1.9.9",
"@vuepress/shared-utils": "1.9.9",
"markdown-it": "13.0.1",
"pinyin-pro": "3.16.0",
"pinyin-pro": "3.16.1",
"remark": "13.0.0",
"remark-frontmatter": "3.0.0",
"remark-gfm": "1.0.0",
Expand Down
8 changes: 4 additions & 4 deletions docs/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions docs/social-media.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ Tiny Tiny RSS 会给所有 iframe 元素添加 `sandbox="allow-scripts"` 属性

:::

## Bluesky (bsky)

### 关键词

<Route author="untitaker" example="/bsky/keyword/hello" path="/bsky/keyword/:keyword" radar="1" rssbud="1" />

### 番剧

<Route author="DIYgod" example="/bilibili/bangumi/media/9192" path="/bilibili/bangumi/media/:mediaid" :paramsDesc="['番剧媒体 id, 番剧主页 URL 中获取']"/>
Expand Down
22 changes: 22 additions & 0 deletions lib/v2/bsky/keyword.js
Original file line number Diff line number Diff line change
@@ -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,
};
};
3 changes: 3 additions & 0 deletions lib/v2/bsky/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/keyword/:keyword': ['untitaker'],
};
13 changes: 13 additions & 0 deletions lib/v2/bsky/radar.js
Original file line number Diff line number Diff line change
@@ -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')}`,
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/bsky/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/keyword/:keyword', require('./keyword'));
};
Loading