1import{r,u as v,j as e,ak as N,am as y,an as C,ao as u,ap as S,aq as B}from"./index-D3i7ThYB.js";import{S as m}from"./search-DUZ_MfSg.js";const k=()=>{const[a,g]=r.useState("all"),[l,h]=r.useState(""),[c,p]=r.useState("newest"),[f,j]=r.useState([]),{current:o}=v(s=>s.user),i=async()=>{const s=await B();s.success&&j(s.blogs)};r.useEffect(()=>{i()},[]);const b=["all",...y],d=f.filter(s=>{const t=a==="all"||s.category===a,w=s.title.toLowerCase().includes(l.toLowerCase())||s.description.toLowerCase().includes(l.toLowerCase());return t&&w}).sort((s,t)=>{switch(c){case"newest":return new Date(t.createdAt)-new Date(s.createdAt);case"oldest":return new Date(s.createdAt)-new Date(t.createdAt);case"popular":return t.numberViews-s.numberViews;case"liked":return t.likes.length-s.likes.length;default:return 0}}),x=d.filter(s=>s.featured),n=d.filter(s=>!s.featured);return e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-100",children:[e.jsx("div",{className:"bg-white shadow-sm border-b border-gray-300",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-4xl font-bold text-gray-900 mb-4",children:e.jsx("span",{className:"bg-gradient-to-r from-blue-600 to-purple-600 bg-clip-text text-transparent",children:"TechBlog"})}),e.jsx("p",{className:"text-xl text-gray-600 max-w-3xl mx-auto",children:"Update the latest news on technology, product reviews, and electronic trends"})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 items-center justify-between",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(m,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-5 h-5"}),e.jsx("input",{type:"text",placeholder:"Search posts...",value:l,onChange:s=>h(s.target.value),className:"w-full outline-none pl-10 pr-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all duration-300"})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(N,{className:"w-5 h-5 text-gray-500"}),e.jsx("select",{value:a,onChange:s=>g(s.target.value),className:"px-4 py-2 outline-none border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white",children:b.map(s=>e.jsx("option",{value:s,children:s==="all"?"All Categories":s},s))})]}),e.jsxs("select",{value:c,onChange:s=>p(s.target.value),className:"px-4 py-2 outline-none border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white",children:[e.jsx("option",{value:"newest",children:"Newest"}),e.jsx("option",{value:"oldest",children:"Oldest"}),e.jsx("option",{value:"popular",children:"Popular"}),e.jsx("option",{value:"liked",children:"Liked"})]}),(o==null?void 0:o.role)==="admin"&&e.jsx(C,{fetchBlogs:i})]})]})]})}),e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12",children:[x.length>0&&e.jsxs("div",{className:"mb-16",children:[e.jsxs("div",{className:"flex items-center mb-8",children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"Featured Posts"}),e.jsx("div",{className:"ml-4 h-1 flex-1 bg-gradient-to-r from-blue-600 to-purple-600 rounded-full"})]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:x.map(s=>e.jsx(u,{post:s,featured:!0},s._id))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center mb-8",children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"Another Posts"}),e.jsx("div",{className:"ml-4 h-1 flex-1 bg-gradient-to-r from-green-500 to-blue-500 rounded-full"})]}),n.length>0?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8",children:n.map(s=>e.jsx(u,{post:s},s._id))}):e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-24 h-24 mx-auto mb-6 bg-gray-100 rounded-full flex items-center justify-center",children:e.jsx(m,{className:"w-12 h-12 text-gray-400"})}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"No results found"}),e.jsx("p",{className:"text-gray-600",children:"Try adjusting your search or filter criteria."})]})]}),n.length>0&&e.jsx("div",{className:"text-center mt-12",children:e.jsxs("button",{className:"inline-flex items-center px-8 py-3 bg-blue-600 text-white font-semibold rounded-xl transform hover:scale-105 transition-all duration-300 shadow-lg hover:shadow-xl cursor-pointer",children:["Load more articles",e.jsx(S,{className:"w-5 h-5 ml-2"})]})})]})]})};export{k as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.