import{t as e}from"./ofetch-Dl6dVB_5.mjs";import{t}from"./parse-date-BdYTmLpo.mjs";import{load as n}from"cheerio";const r={path:`/blog/:category?`,name:`Blog`,url:`cognition.ai/blog`,maintainers:[`Loongphy`,`ttttmr`],example:`/cognition/blog`,categories:[`programming`],features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportRadar:!0,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`cognition.ai/blog/1`,`cognition.ai/blog/:category/1`],target:`/blog/:category?`}],view:0,handler:a,parameters:{category:`Category name, e.g., Research, Tutorials`}},i=e=>{if(!e)return;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);if(t.length!==0)return t.map(e=>({name:e}))};async function a(r){let a=`https://cognition.ai`,{category:o}=r.req.param(),s=o?`/blog/${o}/1`:`/blog/1`,c=new URL(s,a).href,l=n(await e(c)),u=l(`#blog-post-list__list li.blog-post-list__list-item`).toArray().map(e=>{let n=l(e).find(`a.o-blog-preview`).first(),r=n.attr(`href`),o=r?new URL(r,a).href:void 0;if(!o)return;let s=n.find(`h3.o-blog-preview__title`).text().trim();if(!s)return;let c=n.find(`p.o-blog-preview__intro`).text().trim(),u=n.find(`.o-blog-preview__meta-date`).clone();u.find(`.o-blog-preview__meta`).remove();let d=u.text().trim(),f=n.find(`.o-blog-preview__meta-author`).text().trim(),p={title:s,link:o,pubDate:t(d)};c&&(p.description=c);let m=i(f);return m&&(p.author=m),p}).filter(e=>e!==void 0),d=l(`meta[property="og:image"]`).attr(`content`),f=d?new URL(d,a).href:void 0;return{title:l(`title`).text(),description:l(`meta[name="description"]`).attr(`content`),link:c,allowEmpty:!0,item:u,image:f}}export{a as handler,r as route};