Skip to content

Commit

Permalink
feat(route/apnews): Expand range of application (#16355)
Browse files Browse the repository at this point in the history
* feat(route/apnews): Expand range of application

* .
  • Loading branch information
dzx-dzx authored Oct 19, 2024
1 parent 27c56bb commit 57b7cc3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/routes/apnews/topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 57b7cc3

Please sign in to comment.