import{t as e}from"./ofetch-Dl6dVB_5.mjs";import{t}from"./parse-date-BdYTmLpo.mjs";const n=new Set([`交流`,`学习`,`项目`,`资源`,`经验`]),r={hot:{field:`thumbNum`,name:`热门`},new:{field:`createTime`,name:`最新`},recommend:{field:`recommendTime`,name:`推荐`}},i={path:`/posts/:category?/:sort?`,categories:[`programming`],example:`/codefather/posts`,parameters:{category:"分类，可选 `交流`、`学习`、`项目`、`资源`、`经验`，默认为全部",sort:"排序方式，可选 `new`（最新）、`hot`（热门）、`recommend`（推荐），默认为 `new`"},features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`www.codefather.cn/`,`www.codefather.cn`],target:`/posts`}],name:`帖子`,maintainers:[`JackyST0`],handler:a,description:`获取编程导航社区的帖子，支持按热门、最新、推荐排序，支持按分类筛选。`};async function a(i){let a=i.req.param(`category`),o=r[i.req.param(`sort`)||`new`]||r.new,s={current:1,pageSize:20,sortField:o.field,sortOrder:`descend`};a&&n.has(a)&&(s.category=a);let c=await e(`https://api.codefather.cn/api/post/list/page/vo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:s});if(c.code!==0)throw Error(`API error: ${c.message}`);let l=(c.data?.records||[]).map(e=>{let n=e.content||``,r=e.pictureList||[],i=e.user||{},a=e.tags||[],o=`<p>${n.replaceAll(`
`,`<br>`)}</p>`;if(r.length>0){o+=`<div>`;for(let e of r)o+=`<img src="${e}" style="max-width: 100%;" />`;o+=`</div>`}return{title:n.split(`
`)[0]||`无标题`,link:`https://www.codefather.cn/post/${e.id}`,description:o,pubDate:t(e.createTime),author:i.userName,category:[e.category,...a.map(e=>e.tagName)].filter(Boolean),upvotes:e.thumbNum,comments:e.commentNum}}),u=a?`${a} - `:``,d=o.name;return{title:`编程导航 - ${u}${d}帖子`,link:`https://www.codefather.cn/`,description:`编程导航社区${u}${d}帖子`,item:l}}export{i as route};