diff --git a/docs/programming.md b/docs/programming.md
index f3b38f6391..2fe154b318 100644
--- a/docs/programming.md
+++ b/docs/programming.md
@@ -26,9 +26,21 @@ pageClass: routes
## GitChat
-### 最新
+### 最新文章
-
+
+
+| 分类名 | 分类 ID |
+| :------- | :----------------------- |
+| 前端 | 58e84f875295227534aad506 |
+| 后端 | 5d8b7c3786194a1921979122 |
+| 移动开发 | 5d8b7c3786194a1921979123 |
+| 运维 | 5901bd477b61a76bc4016423 |
+| 测试 | 58e84f425295227534aad502 |
+| 架构 | 58e84f6bad952d6b3428af9a |
+| 人工智能 | 58e84f53ec8e9e7b34457809 |
+| 职场 | 58e84f1584c651693437f27c |
+| 互联网 | 5d8b7c3786194a1921979124 |
> GitChat 需要付费订阅, RSS 仅做更新提醒, 不含付费内容.
@@ -268,9 +280,7 @@ GitHub 官方也提供了一些 RSS:
### Scala Blog
-
-默认为All part参数可在url中获得
-
+
## segmentfault
diff --git a/lib/router.js b/lib/router.js
index 2698ea5fbd..63fc690170 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -925,7 +925,7 @@ router.get('/itjuzi/merge', require('./routes/itjuzi/merge'));
router.get('/tanwu/products', require('./routes/tanwu/products'));
// GitChat
-router.get('/gitchat/newest', require('./routes/gitchat/newest'));
+router.get('/gitchat/newest/:category?/:selected?', require('./routes/gitchat/newest'));
// The Guardian
router.get('/guardian/:type', require('./routes/guardian/guardian'));
diff --git a/lib/routes/gitchat/newest.js b/lib/routes/gitchat/newest.js
index d21bd96c35..21c92207b7 100644
--- a/lib/routes/gitchat/newest.js
+++ b/lib/routes/gitchat/newest.js
@@ -1,38 +1,23 @@
const got = require('@/utils/got');
-const cheerio = require('cheerio');
module.exports = async (ctx) => {
- const response = await got({
- method: 'get',
- url: 'https://gitbook.cn/gitchat/news/0/20?searchKey=',
- });
- const $ = cheerio.load(response.data.data);
- const resultItem = $('.col-md-12')
- .map((index, item) => {
- item = $(item);
- const author = item.find('.chat_info_author').text();
+ const category = ctx.params.category && ctx.params.category !== 'all' ? ctx.params.category : '';
+ const selected = ctx.params.selected;
- return {
- title: item.find('.chat_info_title').text(),
- description:
- `作者: ${author}
` +
- item
- .find('.chat_info_desc')
- .text()
- .replace(/\n/g, '
'),
- link: `https://gitbook.cn${item
- .find('a')
- .eq(0)
- .attr('href')}`,
- author,
- };
- })
- .get();
+ const response = await got(`https://gitbook.cn/activities?page=1&type=new&isSelected=${selected ? 'true' : 'false'}${category ? '&category=' + category : ''}`);
+ const list = response.data.data;
+
+ const category_name = category ? list[0].category.categoryName : '';
ctx.state.data = {
- title: 'GitChat-最新',
- link: 'https://gitbook.cn/gitchat/news',
- description: 'GitChat 是一款基于微信平台的知识分享产品。通过这款产品我们希望改变IT知识的学习方式。',
- item: resultItem,
+ title: `GitChat ${category ? category_name + ' ' : ''}最新${selected ? '严选' : ''}`,
+ link: 'https://gitbook.cn/',
+ item: list.map((item) => ({
+ title: item.title,
+ author: item.authorId.customerName,
+ description: `
${item.description}
`,
+ pubDate: new Date(),
+ link: `https://gitbook.cn/gitchat/activity/${item._id}`,
+ })),
};
};