1import{r as a,K as v,j as e,H as N,ak as h,o as _,J as S}from"./index-KSWbwNeY.js";import{Q as c}from"./queryCache-lIY9Vt5H.js";import{T as I}from"./TrendingSkeleton-DiqKpoQk.js";import{L as A}from"./LoadErrorState-reXaOKVb.js";import{S as i,g as r,a as x}from"./seoDefaults-DHsbBPCr.js";import D from"./Footer-DPSMpmUX.js";import{R as E}from"./responsive-heading-DW57rgMc.js";import"./twitter-yEUqfNJX.js";import"./linkedin-B1bA0DJP.js";import"./youtube-CwivUiPT.js";import"./facebook-DahhNxAJ.js";const z=()=>{const[n,o]=a.useState([]),[u,l]=a.useState(!0),[j,d]=a.useState(!1);a.useEffect(()=>{m()},[]);const m=async()=>{d(!1),l(!0);try{const t=c.get("trending_posts");if(t&&t.length>0){o(t),l(!1);return}const s=new Date(Date.now()-24*60*60*1e3).toISOString(),y=new Promise((L,b)=>setTimeout(()=>b(new Error("timeout")),8e3)),{data:w,error:g}=await Promise.race([v.from("posts").select(`id, title, excerpt, image_url, read_time, created_at, published_at, slug, view_count, 2 categories (name), authors!posts_author_id_fkey (name)`).eq("published",!0).gte("published_at",s).lte("published_at",new Date().toISOString()).order("view_count",{ascending:!1}).limit(20),y]);if(g)throw g;const p=w||[];o(p),c.set("trending_posts",p,5*60*1e3)}catch(t){console.error("Error fetching posts:",t);const s=c.get("trending_posts");s&&s.length>0?o(s):d(!0)}finally{l(!1)}},f=t=>new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});return u?e.jsx(I,{}):j?e.jsx(A,{onRetry:m}):e.jsxs(e.Fragment,{children:[e.jsxs(N,{children:[e.jsxs("title",{children:["Trending Stories - ",i]}),e.jsx("meta",{name:"description",content:"Discover the most popular and trending AI, data science, and technology stories on AIM. See what readers are engaging with most."}),e.jsx("meta",{name:"keywords",content:"trending AI news, popular tech articles, most read data science stories"}),e.jsx("link",{rel:"canonical",href:`${r()}/trending`}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:`${r()}/trending`}),e.jsx("meta",{property:"og:title",content:`Trending Stories - ${i}`}),e.jsx("meta",{property:"og:description",content:"Discover the most popular and trending AI, data science, and technology stories on AIM."}),e.jsx("meta",{property:"og:image",content:x(null,r())}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:url",content:`${r()}/trending`}),e.jsx("meta",{name:"twitter:title",content:`Trending Stories - ${i}`}),e.jsx("meta",{name:"twitter:description",content:"Discover the most popular and trending AI, data science, and technology stories on AIM."}),e.jsx("meta",{name:"twitter:image",content:x(null,r())}),n.length>0&&e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"CollectionPage",name:`Trending Stories - ${i}`,description:"Discover the most popular and trending AI, data science, and technology stories on AIM.",url:`${r()}/trending`,publisher:{"@type":"Organization",name:"AIM",logo:{"@type":"ImageObject",url:`${r()}/favicon.png`}},mainEntity:{"@type":"ItemList",numberOfItems:n.length,itemListOrder:"https://schema.org/ItemListOrderDe
2scending",itemListElement:n.slice(0,10).map((t,s)=>({"@type":"ListItem",position:s+1,url:`${r()}/${t.slug}`,name:t.title}))}})})]}),e.jsx("div",{className:"min-h-screen bg-background text-foreground",children:e.jsxs("div",{className:"max-w-[1400px] mx-auto px-4 py-8",children:[e.jsxs("div",{className:"border-b-2 border-black pb-4 mb-8",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(h,{className:"h-8 w-8"}),e.jsx(E,{size:"md",children:"Trending"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Most viewed stories across AIM"})]}),e.jsx("div",{className:"space-y-8",children:n.map((t,s)=>e.jsx("article",{className:"border-b pb-6",style:{borderColor:"#e5e5e5"},children:e.jsxs("div",{className:"flex gap-6",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("span",{className:"font-serif text-5xl font-bold",style:{color:"#ddd"},children:(s+1).toString().padStart(2,"0")})}),e.jsx("div",{className:"flex-1",children:e.jsx(_,{to:`/${t.slug||t.id}`,className:"group",children:e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"flex-1",children:[t.categories&&e.jsx("div",{className:"text-xs font-bold uppercase mb-2",style:{color:"#666"},children:t.categories.name}),e.jsx("h2",{className:"font-serif font-bold text-2xl mb-2 group-hover:underline leading-tight",children:t.title}),e.jsx("p",{className:"text-sm text-gray-700 mb-3 line-clamp-2 leading-relaxed",children:t.excerpt}),e.jsxs("div",{className:"flex items-center gap-3 text-xs",style:{color:"#666"},children:[t.authors&&e.jsx("span",{children:t.authors.name}),e.jsx("span",{children:"â¢"}),e.jsx("span",{children:f(t.published_at||t.created_at)}),t.read_time&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"â¢"}),e.jsx("span",{children:t.read_time})]}),e.jsx("span",{children:"â¢"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(h,{className:"h-3 w-3"}),t.view_count.toLocaleString()," views"]})]})]}),t.image_url&&e.jsx("div",{className:"flex-shrink-0 w-32 h-32 overflow-hidden",children:e.jsx(S,{src:t.image_url,alt:t.title,width:300,height:300,className:"w-full h-full object-cover group-hover:opacity-90 transition-opacity"})})]})})})]})},t.id))})]})}),e.jsx(D,{})]})};export{z 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.