import{j as e}from"./jsx-runtime.D_zvdyIk.js";import{u as g}from"./useTranslation.Dg7DwAC5.js";import{e as x}from"./route.D5BPSNZk.js";import{s as p,c as u}from"./utils.BZbvJs_N.js";import{r as N}from"./index.BIRwh3HZ.js";import{l as d}from"./utils.D6Ui05B2.js";import"./index.RTTH55m1.js";import"./index.3whys8t3.js";import"./router.B9yJslVs.js";import"./site.Deo0TYgJ.js";import"./_commonjsHelpers.CqkleIqs.js";import"./site-config.CgQ_bxrG.js";function z({allPosts:l,relatedPosts:o,leftCount:t,rightCount:i,locale:n}){const{t:m}=g(),{leftPosts:f,rightPosts:c,hasRelatedPosts:a}=N.useMemo(()=>{const s=o.length>0,r=p(l);return{leftPosts:r.slice(0,t),rightPosts:s?o:r.slice(t,t+i),hasRelatedPosts:s}},[l,o,t,i]),h=a?m("post.relatedPosts"):"";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h2",{className:"font-semibold text-2xl text-foreground/80",children:m("post.randomPosts")}),e.jsx("div",{className:"flex flex-col gap-2",children:f.map((s,r)=>e.jsxs("a",{href:d(`/post/${x(s.link??s.slug)}`,n),className:"group flex gap-3 rounded-md p-2 text-sm transition-colors duration-300 hover:bg-foreground/5 hover:text-primary",children:[e.jsx("span",{className:"shrink-0 font-mono text-foreground/30",children:r+1}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[s.categoryName&&e.jsx("div",{className:"truncate text-foreground/50 text-xs",children:s.categoryName}),e.jsx("div",{className:"line-clamp-2 text-foreground/80 transition-colors group-hover:text-primary",children:s.title})]})]},s.slug))})]}),c.length>0&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h2",{className:"font-semibold text-2xl text-foreground/80",children:h}),e.jsx("div",{className:u("flex flex-col gap-2",{"-mt-4 pt-12 md:-mt-5 md:pt-0":!a}),children:c.map((s,r)=>e.jsxs("a",{href:d(`/post/${x(s.link??s.slug)}`,n),className:"group flex gap-3 rounded-md p-2 text-sm transition-colors duration-300 hover:bg-foreground/5 hover:text-primary",children:[e.jsx("span",{className:"shrink-0 font-mono text-foreground/30",children:r+(a?1:t+1)}),e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[s.categoryName&&e.jsx("div",{className:"truncate text-foreground/50 text-xs",children:s.categoryName}),e.jsx("div",{className:"line-clamp-2 text-foreground/80 transition-colors group-hover:text-primary",children:s.title})]})]},s.slug))})]})]})}export{z as default};
