From 57b7cc39ac09d0649eb9115d2e224c2767eb67bf Mon Sep 17 00:00:00 2001 From: Andvari <31068367+dzx-dzx@users.noreply.github.com> Date: Sat, 19 Oct 2024 17:50:21 +0800 Subject: [PATCH] feat(route/apnews): Expand range of application (#16355) * feat(route/apnews): Expand range of application * . --- lib/routes/apnews/topics.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/routes/apnews/topics.ts b/lib/routes/apnews/topics.ts index 5c693c7124019..df0ff55300776 100644 --- a/lib/routes/apnews/topics.ts +++ b/lib/routes/apnews/topics.ts @@ -5,7 +5,7 @@ import { fetchArticle, removeDuplicateByKey } from './utils'; const HOME_PAGE = 'https://apnews.com'; export const route: Route = { - path: '/topics/:topic?', + path: ['/topics/:topic?', '/nav/:nav{.*}?'], categories: ['traditional-media', 'popular'], example: '/apnews/topics/apf-topnews', view: ViewType.Articles, @@ -35,8 +35,9 @@ export const route: Route = { }; async function handler(ctx) { - const { topic = 'trending-news' } = ctx.req.param(); - const url = `${HOME_PAGE}/hub/${topic}`; + const { topic = 'trending-news', nav = '' } = ctx.req.param(); + const useNav = ctx.req.routePath === '/apnews/nav/:nav{.*}?'; + const url = useNav ? `${HOME_PAGE}/${nav}` : `${HOME_PAGE}/hub/${topic}`; const response = await got(url); const $ = load(response.data);