import{t as e}from"./cache-DUthuMSu.mjs";import{n as t,t as n}from"./parse-date-BdYTmLpo.mjs";import{t as r}from"./got-BBDj7u1e.mjs";import{Fragment as i,jsx as a}from"hono/jsx/jsx-runtime";import{load as o}from"cheerio";import{renderToString as s}from"hono/jsx/dom/server";const c=e=>s(a(d,{content:e})),l={path:`/top20`,categories:[`blog`],example:`/zhubai/top20`,parameters:{},features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`analy.zhubai.love/`]}],name:`上周热门 TOP 20`,maintainers:[`nczitzk`],handler:u,url:`analy.zhubai.love/`};async function u(i){let a=i.req.query(`limit`)?Number.parseInt(i.req.query(`limit`)):20,s=`http://analy.zhubai.wiki`,l=new URL(`a/zb/s/ht/pl/wk`,`https://open.zhubai.wiki`).href,{data:u}=await r.post(l),d=u.data.slice(0,a).map(e=>({title:e.pn,link:e.pu??e.pq??e.fp,description:e.pa,author:e.zn,pubDate:t(e.lu.replace(/\.\d+/,``))}));d=await Promise.all(d.map(t=>e.tryGet(t.link,async()=>{let e=t.link.match(/\/(?:pl|pq|fp)\/([\w-]+)\/(\d+)/),{data:i}=await r(`https://${e[1]}.zhubai.love/api/posts/${e[2]}`);return t.title=i.title??t.title,t.description=i.content?c(JSON.parse(i.content)):t.description,t.author=i.author?.name??t.author,t.pubDate=i.created_at?n(i.created_at):t.pubDate,t})));let{data:f}=await r(s),p=o(f),m=p(`link[rel="apple-touch-icon"]`).prop(`href`);return{item:d,title:`${p(`meta[property="og:title"]`).prop(`content`)} - TOP20`,link:s,description:p(`meta[property="og:description"]`).prop(`content`),language:p(`html`).prop(`lang`),image:p(`meta[property="og:image"]`).prop(`content`),icon:m,logo:m,subtitle:p(`meta[property="og:description"]`).prop(`content`),author:p(`meta[name="twitter:site"]`).prop(`content`)}}const d=({content:e})=>a(i,{children:f(e)}),f=e=>e?.map(e=>{if(e.text)return e.text;switch(e.type){case`paragraph`:return a(`p`,{children:f(e.children)});case`link`:return a(`a`,{href:e.url,children:f(e.children)});case`image`:return a(`img`,{src:e.url,height:e.naturalHeight,width:e.naturalWidth});case`list-item`:return a(`li`,{children:f(e.children)});case`bulleted-list`:return a(`ul`,{children:f(e.children)});case`numbered-list`:return a(`ol`,{children:f(e.children)});case`block-quote`:return a(`blockquote`,{children:f(e.children)});case`heading-one`:return a(`h1`,{children:f(e.children)});case`heading-two`:return a(`h2`,{children:f(e.children)});case`heading-three`:return a(`h3`,{children:f(e.children)});case`heading-four`:return a(`h4`,{children:f(e.children)});case`heading-five`:return a(`h5`,{children:f(e.children)});case`heading-six`:return a(`h6`,{children:f(e.children)});default:return null}})??[];export{l as route};