import{t as e}from"./ofetch-Dl6dVB_5.mjs";import{t}from"./cache-DUthuMSu.mjs";import{t as n}from"./parse-date-BdYTmLpo.mjs";import{n as r}from"./utils-BqW13sRQ.mjs";import{load as i}from"cheerio";const a={path:`/topics/:topic`,name:`Topics`,maintainers:[`TonyRL`],handler:o,example:`/bbc/topics/c77jz3md4rwt`,parameters:{topic:`The topic ID to fetch news for, can be found in the URL.`},radar:[{source:[`www.bbc.com/news/topics/:topic`]}],categories:[`traditional-media`]};async function o(a){let{topic:o}=a.req.param(),s=`https://www.bbc.com/news/topics/${o}`,c=i(await e(s)),l=JSON.parse(c(`script#__NEXT_DATA__`).text()).props.pageProps,u=l.page[l.pageKey],d=u.sections[0].content.map(e=>({title:e.title,link:`https://www.bbc.com${e.href}`,description:e.description,pubDate:n(e.metadata.firstUpdated),category:e.metadata.topics,image:e.image?e.image.model.blocks.src:void 0})),f=await Promise.all(d.map(e=>t.tryGet(e.link,async()=>{let{category:t,description:n}=await r(e.link,e);return e.category=t,e.description=n,e})));return{title:u.seo.title,description:u.seo.description,link:s,image:`https://www.bbc.com/favicon.ico`,item:f}}export{a as route};