Skip to content

Commit

Permalink
fix(route): nikkei route paths (#15684)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyRL authored May 24, 2024
1 parent 70a3648 commit 249cedc
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 20 deletions.
11 changes: 1 addition & 10 deletions lib/routes/nikkei/asia/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@ export const route: Route = {
path: '/asia',
categories: ['traditional-media'],
example: '/nikkei/asia',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['asia.nikkei.com/'],
Expand All @@ -25,7 +16,7 @@ export const route: Route = {
name: 'Nikkei Asia Latest News',
maintainers: ['rainrdx'],
handler,
url: 'asia.nikkei.com/',
url: 'asia.nikkei.com',
};

async function handler() {
Expand Down
42 changes: 39 additions & 3 deletions lib/routes/nikkei/cn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,45 @@ import parser from '@/utils/rss-parser';

export const route: Route = {
path: '/cn/*',
name: 'Unknown',
maintainers: [],
name: '中文版新闻',
example: '/nikkei/cn',
maintainers: ['nczitzk'],
handler,
description: `::: tip
如 [中国 经济 日经中文网](https://cn.nikkei.com/china/ceconomy.html) 的 URL 为 \`https://cn.nikkei.com/china/ceconomy.html\` 对应路由为 [\`/nikkei/cn/cn/china/ceconomy\`](https://rsshub.app/nikkei/cn/cn/china/ceconomy)
如 [中國 經濟 日經中文網](https://zh.cn.nikkei.com/china/ceconomy.html) 的 URL 为 \`https://zh.cn.nikkei.com/china/ceconomy.html\` 对应路由为 [\`/nikkei/cn/zh/china/ceconomy\`](https://rsshub.app/nikkei/cn/zh/china/ceconomy)
特别地,当 \`path\` 填入 \`rss\` 后(如路由为 [\`/nikkei/cn/cn/rss\`](https://rsshub.app/nikkei/cn/cn/rss)),此时返回的是 [官方 RSS 的内容](https://cn.nikkei.com/rss.html)
:::`,
radar: [
{
title: '中文版新闻',
source: ['cn.nikkei.com/:category/:type', 'cn.nikkei.com/:category', 'cn.nikkei.com/'],
target: (params) => {
if (params.category && params.type) {
return `/nikkei/cn/cn/${params.category}/${params.type.replace('.html', '')}`;
} else if (params.category && !params.type) {
return `/nikkei/cn/cn/${params.category.replace('.html', '')}`;
} else {
return `/nikkei/cn/cn`;
}
},
},
{
title: '中文版新聞',
source: ['zh.cn.nikkei.com/:category/:type', 'zh.cn.nikkei.com/:category', 'zh.cn.nikkei.com/'],
target: (params) => {
if (params.category && params.type) {
return `/nikkei/cn/zh/${params.category}/${params.type.replace('.html', '')}`;
} else if (params.category && !params.type) {
return `/nikkei/cn/zh/${params.category.replace('.html', '')}`;
} else {
return `/nikkei/cn/zh`;
}
},
},
],
};

async function handler(ctx) {
Expand Down Expand Up @@ -40,7 +76,7 @@ async function handler(ctx) {
officialFeed = await parser.parseURL(currentUrl);
items = officialFeed.items.slice(0, limit).map((item) => ({
title: item.title,
link: new URL(item.attr('href'), rootUrl).href,
link: new URL(item.link, rootUrl).href,
}));
} else {
const response = await got({
Expand Down
9 changes: 5 additions & 4 deletions lib/routes/nikkei/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import got from '@/utils/got';
import { load } from 'cheerio';

export const route: Route = {
path: ['/', '/index'],
name: 'Unknown',
maintainers: [],
path: '/index',
name: 'Home',
example: '/nikkei/index',
maintainers: ['zjysdhr'],
handler,
url: 'www.nikkei.com/',
url: 'www.nikkei.com',
};

async function handler() {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/nikkei/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'The Nikkei 日本経済新聞',
url: 'asia.nikkei.com',
url: 'nikkei.com',
};
4 changes: 2 additions & 2 deletions lib/routes/nikkei/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { art } from '@/utils/render';
import path from 'node:path';

export const route: Route = {
path: '/:category/:article_type?',
path: '/news/:category/:article_type?',
categories: ['traditional-media'],
example: '/nikkei/news',
example: '/nikkei/news/news',
parameters: { category: 'Category, see table below', article_type: 'Only includes free articles, set `free` to enable, disabled by default' },
radar: [
{
Expand Down

0 comments on commit 249cedc

Please sign in to comment.