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{Fragment as r,jsx as i,jsxs as a}from"hono/jsx/jsx-runtime";import{load as o}from"cheerio";import{renderToString as s}from"hono/jsx/dom/server";import{raw as c}from"hono/html";const l=async l=>{let u=Number.parseInt(l.req.query(`limit`)??`30`,10),d=`https://www.thebrain.com`,f=new URL(`blog`,d).href,p=o(await e(f)),m=p(`html`).attr(`lang`)??`en`,h=p(`div.blog-row`).slice(0,u).toArray().map(e=>{let t=p(e),o=t.find(`h4 a`),l=o.text(),u=t.find(`div.round-corner-images img`).attr(`src`)?`https:${t.find(`div.round-corner-images img`).attr(`src`)?.split(/\?/)[0]}`:void 0,f=s(a(r,{children:[u?i(`figure`,{children:i(`img`,{src:u,alt:l})}):null,t.find(`p.small-text`).next().html()?c(t.find(`p.small-text`).next().html()):null]})),h=t.find(`p.small-text`).text(),g=o.attr(`href`),_=h;return{title:l,description:f,pubDate:h?n(h):void 0,link:g?new URL(g,d).href:void 0,content:{html:f,text:f},image:u,banner:u,updated:_?n(_):void 0,language:m}});return h=await Promise.all(h.map(r=>r.link?t.tryGet(r.link,async()=>{let t=o(await e(r.link)),i=t(`h2.gradient-heading`).text()||t(`h1.gradient-heading`).text();t(`h2.gradient-heading`).remove(),t(`div#shareDiv`).remove();let a=t(`div.blog-content`).html()||t(`div.docs-section`).html(),s=t(`div.blog-meta`).text(),c=t(`a.under-category`).toArray(),l=[...new Set(c.map(e=>t(e).text()).filter(Boolean))],u=t(`img.avatar`).toArray().map(e=>{let n=t(e).parent().next().find(`a`);return{name:n.text(),url:n.attr(`href`)?new URL(n.attr(`href`),d).href:void 0,avatar:`https:${t(e).attr(`src`)?.split(/\?/)[0]}`}}),f=s,p={title:i,description:a,pubDate:s?n(s):r.pubDate,category:l,author:u,content:{html:a,text:a},updated:f?n(f):r.updated,language:m};return{...r,...p}}):r)),{title:p(`title`).text(),link:f,item:h,allowEmpty:!0,image:p(`img.navbar-logo`).attr(`src`)?new URL(p(`img.navbar-logo`).attr(`src`),d).href:void 0,language:m,id:f}},u={path:`/blog`,name:`Blog`,url:`www.thebrain.com`,maintainers:[`nczitzk`],handler:l,example:`/thebrain/blog`,parameters:void 0,description:void 0,categories:[`new-media`],features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportRadar:!0,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`www.thebrain.com/blog`],target:`/blog`}],view:0};export{l as handler,u as route};