feat(route/apnews): Expand range of application (#16355)
* feat(route/apnews): Expand range of application * .
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user