From c05427292c65451cd5e7a83032878e06d9cd8f03 Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Thu, 11 Mar 2021 13:55:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(route):=20=E5=85=89=E8=B0=B7=E7=A4=BE?= =?UTF-8?q?=E5=8C=BA=E9=87=8D=E5=A4=8D=E5=B8=96=E5=AD=90=20(#7110)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/bbs.md | 8 ++++---- lib/router.js | 2 +- lib/routes/guanggoo/index.js | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/bbs.md b/docs/bbs.md index f927bd8f6e..48a4ba6929 100644 --- a/docs/bbs.md +++ b/docs/bbs.md @@ -248,11 +248,11 @@ pageClass: routes ### 子论坛 - + -| 首页 | 你问我答 | 同城活动 | IT 技术 | 金融财经 | 创业创客 | 城市建设 | -| ----- | -------- | -------- | ------- | -------- | -------- | -------- | -| index | qna | lowshine | it | finance | startup | city | +| 首页 | 你问我答 | 同城活动 | IT 技术 | 金融财经 | 创业创客 | 城市建设 | +| ---- | -------- | -------- | ------- | -------- | -------- | -------- | +| | qna | lowshine | it | finance | startup | city | diff --git a/lib/router.js b/lib/router.js index 42b0dcf697..9104088b82 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3145,7 +3145,7 @@ router.get('/gelonghui/subject/:id', require('./routes/gelonghui/subject')); router.get('/gelonghui/keyword/:keyword', require('./routes/gelonghui/keyword')); // 光谷社区 -router.get('/guanggoo/:caty', require('./routes/guanggoo/index')); +router.get('/guanggoo/:category?', require('./routes/guanggoo/index')); // 万维读者 router.get('/creaders/headline', require('./routes/creaders/headline')); diff --git a/lib/routes/guanggoo/index.js b/lib/routes/guanggoo/index.js index faaf9d7034..70cc605bd5 100644 --- a/lib/routes/guanggoo/index.js +++ b/lib/routes/guanggoo/index.js @@ -36,7 +36,9 @@ const config = { }; module.exports = async (ctx) => { - const cfg = config[ctx.params.caty]; + const category = ctx.params.category || 'index'; + + const cfg = config[category]; if (!cfg) { throw Error('Bad category. See docs'); } @@ -54,7 +56,7 @@ module.exports = async (ctx) => { item = $(item); return { title: item.text(), - link: url.resolve(rootUrl, item.attr('href')), + link: url.resolve(rootUrl, item.attr('href').split('#')[0]), }; }) .get();