fix(route/yahoo): allow unlisted provider
This commit is contained in:
parent
d7f4dbbe3f
commit
ec6df29727
|
|
@ -9,19 +9,15 @@ module.exports = async (ctx) => {
|
|||
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 20;
|
||||
const providerList = await getProviderList(region, ctx.cache.tryGet);
|
||||
const provider = providerList.find((p) => p.key === providerId);
|
||||
if (!provider) {
|
||||
throw Error(`Unknown providerId: ${providerId}
|
||||
Please double check the <a href="${ctx.origin}/yahoo/news/providers/${region}">provider list</a>.`);
|
||||
}
|
||||
|
||||
const response = await getArchive(region, limit, null, provider.key);
|
||||
const response = await getArchive(region, limit, null, providerId);
|
||||
const list = parseList(region, response);
|
||||
|
||||
const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Yahoo 新聞 - ${provider.title}`,
|
||||
link: provider.link,
|
||||
title: `Yahoo 新聞 - ${provider?.title ?? ''}`,
|
||||
link: provider?.link ?? `https://${region}.news.yahoo.com`,
|
||||
image: 'https://s.yimg.com/cv/apiv2/social/images/yahoo_default_logo-1200x1200.png',
|
||||
item: items,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue