From 952b0b7115a8a65b2d17a969c59a22130a16a7a5 Mon Sep 17 00:00:00 2001
From: Hengyu <76626546+5upernova-heng@users.noreply.github.com>
Date: Tue, 4 Apr 2023 00:21:44 +0800
Subject: [PATCH] fix(route): fix the error of route hk01/channel when channel
does not have publishName (#12152)
* Fix hk01/channel when channel does not have publishName
* additional fix to the same problem
* Add(route): hk01 latest
* Fix radar
* docs: fix category
---------
---
docs/new-media.md | 26 ++++++++++++++++++++++++++
docs/traditional-media.md | 22 ----------------------
lib/v2/hk01/channel.js | 4 ++--
lib/v2/hk01/latest.js | 20 ++++++++++++++++++++
lib/v2/hk01/maintainer.js | 1 +
lib/v2/hk01/radar.js | 16 +++++++++++-----
lib/v2/hk01/router.js | 1 +
7 files changed, 61 insertions(+), 29 deletions(-)
create mode 100644 lib/v2/hk01/latest.js
diff --git a/docs/new-media.md b/docs/new-media.md
index daed99a07..dfd359f19 100644
--- a/docs/new-media.md
+++ b/docs/new-media.md
@@ -4205,6 +4205,32 @@ wechat-feeds 来源[已停止更新](https://github.com/hellodword/wechat-feeds/
+## 香港 01
+
+### 热门
+
+
+
+### 栏目
+
+
+
+### 子栏目
+
+
+
+### 专题
+
+
+
+### 标签
+
+
+
+### 即時
+
+
+
## 香港高登
### 頻道
diff --git a/docs/traditional-media.md b/docs/traditional-media.md
index 3eec061e9..cd48bf720 100644
--- a/docs/traditional-media.md
+++ b/docs/traditional-media.md
@@ -2217,28 +2217,6 @@ category 对应的关键词有
-## 香港 01
-
-### 热门
-
-
-
-### 栏目
-
-
-
-### 子栏目
-
-
-
-### 专题
-
-
-
-### 标签
-
-
-
## 香港電台
### 新聞
diff --git a/lib/v2/hk01/channel.js b/lib/v2/hk01/channel.js
index 8d6f713d9..95cacf8ea 100644
--- a/lib/v2/hk01/channel.js
+++ b/lib/v2/hk01/channel.js
@@ -15,9 +15,9 @@ module.exports = async (ctx) => {
const items = await ProcessItems(response.data.items, ctx.query.limit, ctx.cache.tryGet);
ctx.state.data = {
- title: `${response.data.category.publishName} | 香港01`,
+ title: response.data.category ? `${response.data.category.publishName} | 香港01` : `Channel: ${id} | 香港01`,
link: currentUrl,
item: items,
- image: response.data.category.icon,
+ image: response.data.category ? response.data.category.icon : null,
};
};
diff --git a/lib/v2/hk01/latest.js b/lib/v2/hk01/latest.js
new file mode 100644
index 000000000..4018ca5e9
--- /dev/null
+++ b/lib/v2/hk01/latest.js
@@ -0,0 +1,20 @@
+const got = require('@/utils/got');
+const { rootUrl, apiRootUrl, ProcessItems } = require('./utils');
+
+module.exports = async (ctx) => {
+ const currentUrl = `${rootUrl}/latest`;
+ const apiUrl = `${apiRootUrl}/v2/page/latest`;
+
+ const response = await got({
+ method: 'get',
+ url: apiUrl,
+ });
+
+ const items = await ProcessItems(response.data.items, ctx.query.limit, ctx.cache.tryGet);
+
+ ctx.state.data = {
+ title: '即時 | 香港01',
+ link: currentUrl,
+ item: items,
+ };
+};
diff --git a/lib/v2/hk01/maintainer.js b/lib/v2/hk01/maintainer.js
index 8e3eec4d8..46d5a3055 100644
--- a/lib/v2/hk01/maintainer.js
+++ b/lib/v2/hk01/maintainer.js
@@ -1,6 +1,7 @@
module.exports = {
'/channel/:id': ['hoilc', 'Fatpandac', 'nczitzk'],
'/hot': ['hoilc', 'Fatpandac', 'nczitzk'],
+ '/latest': ['5upernova-heng'],
'/issue/:id': ['hoilc', 'Fatpandac', 'nczitzk'],
'/tag/:id': ['hoilc', 'Fatpandac', 'nczitzk'],
'/zone/:id': ['hoilc', 'Fatpandac', 'nczitzk'],
diff --git a/lib/v2/hk01/radar.js b/lib/v2/hk01/radar.js
index ea7c30453..c749fdcea 100644
--- a/lib/v2/hk01/radar.js
+++ b/lib/v2/hk01/radar.js
@@ -4,34 +4,40 @@ module.exports = {
'.': [
{
title: '热门',
- docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01-re-men',
+ docs: 'https://docs.rsshub.app/new-media.html#xiang-gang-01-re-men',
source: ['/hot', '/'],
target: '/hk01/hot',
},
{
title: '栏目',
- docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01-lan-mu',
+ docs: 'https://docs.rsshub.app/new-media.html#xiang-gang-01-lan-mu',
source: ['/zone/:id', '/'],
target: '/hk01/zone/:id?',
},
{
title: '子栏目',
- docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01-zi-lan-mu',
+ docs: 'https://docs.rsshub.app/new-media.html#xiang-gang-01-zi-lan-mu',
source: ['/channel/:id', '/'],
target: '/hk01/channel/:id?',
},
{
title: '专题',
- docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01-zhuan-ti',
+ docs: 'https://docs.rsshub.app/new-media.html#xiang-gang-01-zhuan-ti',
source: ['/issue/:id', '/'],
target: '/hk01/issue/:id?',
},
{
title: '标签',
- docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01-biao-qian',
+ docs: 'https://docs.rsshub.app/new-media.html#xiang-gang-01-biao-qian',
source: ['/tag/:id', '/'],
target: '/hk01/tag/:id?',
},
+ {
+ title: '即時',
+ docs: 'https://docs.rsshub.app/new-media.html#xiang-gang-01-ji-shi',
+ source: ['/latest', '/'],
+ target: '/hk01/latest',
+ },
],
},
};
diff --git a/lib/v2/hk01/router.js b/lib/v2/hk01/router.js
index 4c10ee89f..ef105c522 100644
--- a/lib/v2/hk01/router.js
+++ b/lib/v2/hk01/router.js
@@ -2,6 +2,7 @@ module.exports = function (router) {
router.get('/channel/:id?', require('./channel'));
router.get('/hot', require('./hot'));
router.get('/issue/:id?', require('./issue'));
+ router.get('/latest', require('./latest'));
router.get('/tag/:id?', require('./tag'));
router.get('/zone/:id?', require('./zone'));
};