1import{R as h,m as N,k as v,n as y,r as m,u as w,j as e,l as k,o as q,X as S,q as L,L as u,F as $}from"./index-BCW6nnV8.js";import{S as d}from"./skeleton-DrEiwWGX.js";function I(){const r=h.useSearch(),t=r.page??1,b=h.useLoaderData(),n=N({from:"/blogs"}),p=v(y),[o,c]=m.useState(r.q??"");m.useEffect(()=>c(r.q??""),[r.q]),m.useEffect(()=>{const s=setTimeout(()=>{(o||"")!==(r.q??"")&&n({search:{...r,q:o||void 0,page:1},replace:!0})},250);return()=>clearTimeout(s)},[o]);const{data:i,isLoading:f,isError:j}=w({queryKey:["blog-posts",t,r.tag??"",r.q??"",r.sort??"newest"],queryFn:()=>p({data:{page:t,tag:r.tag,q:r.q,sort:r.sort}}),staleTime:1e3*60,initialData:b}),x=i?.posts??[],l=i?.totalPages??1,g=i?.tags??[];return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(k,{}),e.jsxs("main",{className:"mx-auto max-w-7xl px-4 md:px-6 py-12",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-display font-bold tracking-tight",children:"Gel Blaster News, Guides, and Tactical Tips"}),e.jsx("p",{className:"mt-2 text-muted-foreground max-w-2xl",children:"Gel blaster guides, reviews, and the latest news â synced live from our store."})]}),e.jsxs("div",{className:"mb-8 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:items-center",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(q,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx("input",{type:"search","aria-label":"Search articles",value:o,onChange:s=>c(s.target.value),placeholder:"Search articles, tags, keywordsâ¦",className:"w-full rounded-md border border-border bg-surface pl-9 pr-9 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:border-brand"}),o&&e.jsx("button",{type:"button",onClick:()=>c(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":"Clear search",children:e.jsx(S,{className:"h-4 w-4"})})]}),e.jsxs("select",{"aria-label":"Sort articles",value:r.sort??"newest",onChange:s=>n({search:{...r,sort:s.target.value,page:1},replace:!0}),className:"rounded-md border border-border bg-surface px-3 py-2 text-sm focus:outline-none focus:border-brand",children:[e.jsx("option",{value:"newest",children:"Latest"}),e.jsx("option",{value:"oldest",children:"Oldest"})]})]}),g.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>n({search:{...r,tag:void 0,page:1},replace:!0}),className:`rounded-full border px-3 py-1 text-xs font-semibold transition ${r.tag?"border-border bg-surface text-muted-foreground hover:border-brand hover:text-brand":"border-brand bg-brand text-background"}`,children:"All"}),g.map(s=>e.jsx("button",{type:"button",onClick:()=>n({search:{...r,tag:s,page:1},replace:!0}),className:`rounded-full border px-3 py-1 text-xs font-semibold transition ${r.tag===s?"border-brand bg-brand text-background":"border-border bg-surface text-muted-foreground hover:border-brand hover:text-brand"}`,children:s},s))]})]}),f?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:Array.from({length:6}).map((s,a)=>e.jsxs("div",{className:"rounded-xl overflow-hidden border border-border bg-surface",children:[e.jsx(d,{className:"aspect-video w-full"}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsx(d,{className:"h-3 w-16"}),e.jsx(d,{className:"h-5 w-3/4"}),e.jsx(d,{className:"h-4 w-full"}),e.jsx(d,{className:"h-4 w-5/6"})]})]},a))}):j?e.jsxs("div",{className:"rounded-xl border border-dashed border-border p-10 text-center",children:[e.jsx("p",{className:"text-lg font-semibold",children:"We couldn't reach the blog right now"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Please refresh in a moment."})]}):x.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-border p-10 text-center",children:[e.jsx("p",{className:"text-lg font-semibold",children:"No articles match your filters"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Try clearing search or category."})]}):e.jsxs(e.Fragment,{children:[e.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify({"@context":"https://schema.org","@type":"ItemList",itemListElement:x.map((s,a)=>({"@type":"ListItem",position:a+1,url:`${L}/blog/${s.handle}`,name:s.title,image:s.imageUrl||void 0}))})}}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:x.map(s=>e.jsxs(u,{to:"/blog/$handle",params:{handle:s.handle},className:"group rounded-xl overflow-hidden border border-border bg-surface hover:border-brand transition",children:[e.jsx("div",{className:"aspect-video overflow-hidden bg-surface/70",children:e.jsx("img",{src:s.imageUrl||"/og-image.png",alt:s.title,className:"h-full w-full object-cover group-hover:scale-105 transition",loading:"lazy",decoding:"async"})}),e.jsxs("div",{className:"p-5",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-brand font-semibold",children:s.tags[0]??"News"}),e.jsx("h2",{className:"mt-2 text-xl font-semibold group-hover:text-brand transition",children:s.title}),s.excerpt&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground line-clamp-3",children:s.excerpt}),e.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:[s.publishedAt??"",s.author?` · ${s.author}`:"",` · ${s.readingMinutes} min read`]}),s.tags.length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:s.tags.slice(0,3).map(a=>e.jsx("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:a},a))})]})]},s.url))}),l>1&&e.jsxs("div",{className:"mt-8 flex items-center justify-between gap-4 border-t border-border pt-6 text-sm",children:[e.jsx(u,{to:"/blogs",search:{...r,page:t>1?t-1:1},className:`transition hover:text-brand ${t<=1?"pointer-events-none opacity-40":""}`,children:"â Previous"}),e.jsxs("p",{className:"text-muted-foreground",children:["Page ",t," of ",l]}),e.jsx(u,{to:"/blogs",search:{...r,page:t<l?t+1:l},className:`transition hover:text-brand ${t>=l?"pointer-events-none opacity-40":""}`,children:"Next â"})]})]})]}),e.jsx($,{})]})}
1export{I as component};
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.