Skip to content

Commit

Permalink
feat(route): add 火线 (#12784)
Browse files Browse the repository at this point in the history
* feat(route): add 火线

* fix pr

* fix pr again

* fix pr again and again.
  • Loading branch information
p7e4 authored Jul 14, 2023
1 parent c01a9e4 commit 5ba92d6
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/bbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,12 @@ pageClass: routes

</Route>

## 火线

### Zone

<Route author="p7e4" example="/huoxian/zone" path="/huoxian/zone"/>

## 集思录

### 广场
Expand Down
3 changes: 3 additions & 0 deletions lib/v2/huoxian/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/zone': ['p7e4'],
};
11 changes: 11 additions & 0 deletions lib/v2/huoxian/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
'huoxian.cn': {
_name: '火线',
zone: [
{
title: 'Zone',
docs: 'https://docs.rsshub.app/bbs.html#huo-xian',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/huoxian/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/zone', require('./zone'));
};
19 changes: 19 additions & 0 deletions lib/v2/huoxian/zone.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const { data } = await got('https://zone.huoxian.cn/api/discussions?sort=-createdAt');
const items = data.data.map((item) => ({
title: item.attributes.title,
link: `https://zone.huoxian.cn/d/${item.attributes.slug}`,
description: data.included.find((i) => i.id === item.relationships.firstPost.data.id).attributes.contentHtml,
pubDate: parseDate(item.attributes.createdAt),
author: data.included.find((i) => i.id === item.relationships.user.data.id).attributes.displayName,
category: data.included.filter((i) => item.relationships.tags.data.map((t) => t.id).includes(i.id) && i.type === 'tags').map((i) => i.attributes.name),
}));
ctx.state.data = {
title: '火线 Zone-安全攻防社区',
link: 'https://zone.huoxian.cn/',
item: items,
};
};

0 comments on commit 5ba92d6

Please sign in to comment.