diff --git a/lib/router.js b/lib/router.js
index 76f2a5b44f9187..d1f5dda1ab6038 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -2039,7 +2039,7 @@ router.get('/anki/changes', lazyloadRouteHandler('./routes/anki/changes'));
router.get('/abc/:id?', lazyloadRouteHandler('./routes/abc'));
// 台湾中央通讯社
-router.get('/cna/:id?', lazyloadRouteHandler('./routes/cna/index'));
+// router.get('/cna/:id?', lazyloadRouteHandler('./routes/cna/index'));
// 华为心声社区
router.get('/huawei/xinsheng/:caty?/:order?/:keyword?', lazyloadRouteHandler('./routes/huawei/xinsheng/index'));
diff --git a/lib/routes/cna/index.js b/lib/v2/cna/index.js
similarity index 67%
rename from lib/routes/cna/index.js
rename to lib/v2/cna/index.js
index 36b12d8538fdbb..d33fb28ef0f63d 100644
--- a/lib/routes/cna/index.js
+++ b/lib/v2/cna/index.js
@@ -1,15 +1,17 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
+const { parseDate } = require('@/utils/parse-date');
+const timezone = require('@/utils/timezone');
module.exports = async (ctx) => {
- ctx.params.id = ctx.params.id || 'aall';
+ const id = ctx.params.id || 'aall';
let rootUrl;
- if (/^\d+$/.test(ctx.params.id)) {
- rootUrl = `https://www.cna.com.tw/topic/newstopic/${ctx.params.id}.aspx`;
+ if (/^\d+$/.test(id)) {
+ rootUrl = `https://www.cna.com.tw/topic/newstopic/${id}.aspx`;
} else {
- rootUrl = `https://www.cna.com.tw/list/${ctx.params.id}.aspx`;
+ rootUrl = `https://www.cna.com.tw/list/${id}.aspx`;
}
const response = await got({
method: 'get',
@@ -17,17 +19,17 @@ module.exports = async (ctx) => {
});
const $ = cheerio.load(response.data);
- const list = $('#jsMainList li a div h2')
- .slice(0, 10)
- .map((_, item) => {
+ const list = $('.mainList li a div h2')
+ .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 10)
+ .toArray()
+ .map((item) => {
item = $(item);
return {
title: item.text(),
link: item.parents('a').attr('href'),
- pubDate: new Date(item.next().text() + ' GMT+8').toUTCString(),
+ pubDate: timezone(parseDate(item.next().text()), +8),
};
- })
- .get();
+ });
const items = await Promise.all(
list.map((item) =>
diff --git a/lib/v2/cna/maintainer.js b/lib/v2/cna/maintainer.js
new file mode 100644
index 00000000000000..77e7f46e2f9997
--- /dev/null
+++ b/lib/v2/cna/maintainer.js
@@ -0,0 +1,3 @@
+module.exports = {
+ '/:id?': ['nczitzk'],
+};
diff --git a/lib/v2/cna/radar.js b/lib/v2/cna/radar.js
new file mode 100644
index 00000000000000..92cec6d1b42db5
--- /dev/null
+++ b/lib/v2/cna/radar.js
@@ -0,0 +1,13 @@
+module.exports = {
+ 'cna.com.tw': {
+ _name: '中央通訊社',
+ '.': [
+ {
+ title: '分类',
+ docs: 'https://docs.rsshub.app/routes/traditional-media#zhong-yang-tong-xun-she',
+ source: ['/list/:id', '/topic/newstopic/:id'],
+ target: (params) => `/cna/${params.id.replace('.aspx', '')}`,
+ },
+ ],
+ },
+};
diff --git a/lib/v2/cna/router.js b/lib/v2/cna/router.js
new file mode 100644
index 00000000000000..a5d65c468f4c46
--- /dev/null
+++ b/lib/v2/cna/router.js
@@ -0,0 +1,3 @@
+module.exports = (router) => {
+ router.get('/:id?', require('./'));
+};
diff --git a/website/docs/routes/traditional-media.md b/website/docs/routes/traditional-media.md
index 409b1d23544a80..3aa4b9d8f1386c 100644
--- a/website/docs/routes/traditional-media.md
+++ b/website/docs/routes/traditional-media.md
@@ -2339,18 +2339,6 @@ category 对应的关键词有
-## 台湾中央通讯社 {#tai-wan-zhong-yang-tong-xun-she}
-
-### 分类 {#tai-wan-zhong-yang-tong-xun-she-fen-lei}
-
-
-
-| 即時 | 政治 | 國際 | 兩岸 | 產經 | 證券 | 科技 | 生活 | 社會 | 地方 | 文化 | 運動 | 娛樂 |
-| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
-| aall | aipl | aopl | acn | aie | asc | ait | ahel | asoc | aloc | acul | aspt | amov |
-
-
-
## 天下雜誌 {#tian-xia-za-zhi}
### 最新上線 {#tian-xia-za-zhi-zui-xin-shang-xian}
@@ -2772,6 +2760,18 @@ category 对应的关键词有
+## 中央通讯社 {#zhong-yang-tong-xun-she}
+
+### 分类 {#zhong-yang-tong-xun-she-fen-lei}
+
+
+
+| 即時 | 政治 | 國際 | 兩岸 | 產經 | 證券 | 科技 | 生活 | 社會 | 地方 | 文化 | 運動 | 娛樂 |
+| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
+| aall | aipl | aopl | acn | aie | asc | ait | ahel | asoc | aloc | acul | aspt | amov |
+
+
+
## 组织人事报 {#zu-zhi-ren-shi-bao}
### 电子报 {#zu-zhi-ren-shi-bao-dian-zi-bao}