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{n as a}from"./utils-GrwaCrU3.mjs";import{load as o}from"cheerio";const s={path:`/blog/:column?`,categories:[`blog`],example:`/caixin/blog/zhangwuchang`,parameters:{column:`博客名称，可在博客主页的 URL 找到`},features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},name:`用户博客`,maintainers:[],handler:c,description:`通过提取文章全文，以提供比官方源更佳的阅读体验.`};async function c(s){let c=s.req.param(`column`),{limit:l=20}=s.req.query();if(c){if(!i(c))throw new r(`Invalid column`);let l=`https://${c}.blog.caixin.com`,{data:u}=await n(l),d=o(u)(`div.indexMainConri > script[type="text/javascript"]`).text().slice(15).split(`;`)[0].replaceAll(/\s/g,``),f=d.match(/id:"(\d+)"/)[1],p=d.match(/name:"(.*?)"/)[1],m=d.match(/avatar:"(.*?)"/)[1],h=d.match(/introduce:"(.*?)"/)[1],{data:{data:g}}=await n(`https://blog.caixin.com/blog-api/post/posts`,{searchParams:{page:1,size:s.req.query(`limit`)?Number.parseInt(s.req.query(`limit`)):20,content:``,authorId:f,sort:`publishTime`,direction:`DESC`}}),_=g.map(e=>({title:e.title,description:e.brief,author:e.displayName,link:e.guid.replace(`http://`,`https://`),pubDate:t(e.publishTime,`x`)})),v=await Promise.all(_.map(t=>e.tryGet(t.link,()=>a(t))));return{title:`财新博客 - ${p}`,link:l,description:h,image:m,item:v}}else{let{data:r}=await n(`https://blog.caixin.com/blog-api/post/index`,{searchParams:{page:1,size:l}}),i=r.data.map(e=>({title:e.title,description:e.brief,author:e.authorName,link:e.postUrl.replace(`http://`,`https://`),pubDate:t(e.publishTime,`x`)}));return{title:`财新博客 - 全部`,link:`https://blog.caixin.com`,item:await Promise.all(i.map(t=>e.tryGet(t.link,()=>a(t))))}}}export{s as route};