import{t as e}from"./cache-DUthuMSu.mjs";import{t}from"./parse-date-BdYTmLpo.mjs";import{t as n}from"./got-BBDj7u1e.mjs";import{t as r}from"./invalid-parameter-DLv2wPKB.mjs";import{t as i}from"./valid-host-CeDzTNj_.mjs";import{load as a}from"cheerio";const o={path:`/:domain/tag/:tag`,name:`Unknown`,maintainers:[],handler:s};async function s(o){let{domain:s=`news`,tag:c}=o.req.param();if(!i(s))throw new r(`Invalid domain`);let l=`https://${s}.gamme.com.tw`,u=`${l}/tag/${c}`,{data:d}=await n(u),f=a(d),p=f(`#category_new li a, .List-4 h3 a`).toArray().map(e=>(e=f(e),{title:e.attr(`title`)||e.text(),link:e.attr(`href`)})),m=await Promise.all(p.map(r=>e.tryGet(r.link,async()=>{let{data:e}=await n(r.link),i=a(e);return i(`.entry img`).each((e,t)=>{(t.attribs[`data-original`]||t.attribs[`data-src`])&&(t.attribs.src=t.attribs[`data-original`]||t.attribs[`data-src`],delete t.attribs[`data-original`],delete t.attribs[`data-src`])}),r.author=i(`.author_name`).text().trim(),r.category=i(`.tags a`).toArray().map(e=>i(e).text()),i(`.social_block, .tags`).remove(),r.pubDate=t(i(`.postDate`).attr(`content`)),r.description=i(`.entry`).html(),r})));return{title:`${c} | ${s===`news`?`宅宅新聞`:`西斯新聞`}`,description:f(`meta[name=description]`).attr(`content`),link:u,image:s===`news`?`${l}/blogico.ico`:`${l}/favicon.ico`,item:m}}export{o as route};