PageSourceSearch

https://analyticsindiamag.com/assets/CategoryDetail-qlhxOfYp.js

js analyticsindiamag.com collected 2026-09-24 08:26:25 UTC 14,038 bytes, 19 lines download raw bytes

1import{ac as Y,r as o,U as T,K as $,j as e,ah as B,H as Z,m as G,o as h,J as f,$ as O,ak as ee,B as te,L as se,d as ae}from"./index-KSWbwNeY.js";import H from"./Footer-DPSMpmUX.js";import{B as re}from"./BreadcrumbSchema-BU2Ysrs6.js";import{a as K,g as ie}from"./seoDefaults-DHsbBPCr.js";import{C as ne}from"./CategoryPostSkeleton-D5Fg6Jxj.js";import{A as M}from"./AnimatedSection-3iB-d0Yw.js";import"./twitter-yEUqfNJX.js";import"./linkedin-B1bA0DJP.js";import"./youtube-CwivUiPT.js";import"./facebook-DahhNxAJ.js";import"./card-CwL_ed79.js";const y=20,je=()=>{var D,U;const{slug:p}=Y(),[x,k]=o.useState([]),[J,I]=o.useState(0),[j,E]=o.useState(!0),[S,A]=o.useState(!1),{data:s,isLoading:Q}=T({queryKey:["category",p],queryFn:async()=>{if(!p)return null;const{data:t,error:a}=await $.from("categories").select("id, name, slug, count, access_level, description, meta_title, meta_description").eq("slug",p).single();if(a){if(a.code==="PGRST116")return null;throw a}return t},staleTime:5*60*1e3,retry:!1}),{data:l,isLoading:V}=T({queryKey:["category-posts",s==null?void 0:s.id],queryFn:async()=>{if(!(s!=null&&s.id))return[];const{data:t,error:a}=await $.from("posts").select(`
2          id,
3          title,
4          excerpt,
5          image_url,
6          created_at,
7          published_at,
8          read_time,
9          slug,
10          satirical_take,
11          view_count,
12          authors!posts_author_id_fkey (name),
13          categories (name)
14        `).eq("published",!0).eq("category_id",s.id).order("published_at",{ascending:!1,nullsFirst:!1}).limit(200);if(a)throw a;return t||[]},enabled:!!(s!=null&&s.id),staleTime:2*60*1e3}),{heroPost:i,sidebarPosts:q,featuredGridPosts:z,trendingPosts:C,excludeIds:g}=o.useMemo(()=>{if(!l||l.length===0)return{heroPost:void 0,sidebarPosts:[],featuredGridPosts:[],trendingPosts:[],excludeIds:new Set};const t=new Set,a=c=>{const n=[];for(const d of l){if(n.length>=c)break;t.has(d.id)||(t.add(d.id),n.push(d))}return n},r=a(1)[0],m=a(4),L=a(4),_=[...l.filter(c=>!t.has(c.id))].sort((c,n)=>(n.view_count||0)-(c.view_count||0)).slice(0,5);return _.forEach(c=>t.add(c.id)),{heroPost:r,sidebarPosts:m,featuredGridPosts:L,trendingPosts:_,excludeIds:t}},[l]),F=o.useCallback(async(t,a=!1)=>{if(!(!(s!=null&&s.id)||g.size===0)){A(!0);try{const r=t*y,m=Array.from(g),L=a?[]:x.map(d=>d.id),R=[...m,...L],{data:_,error:c}=await $.from("posts").select(`
15          id, title, excerpt, image_url, created_at, published_at,
16          read_time, slug, satirical_take, view_count,
17          authors!posts_author_id_fkey (name),
18          categories (name)
19        `).eq("published",!0).eq("category_id",s.id).not("id","in",`(${R.join(",")})`).order("published_at",{ascending:!1,nullsFirst:!1}).range(0,y-1),n=_||[];n.length<y&&E(!1),k(a?n:d=>[...d,...n])}catch(r){console.error("Error loading more stories:",r)}finally{A(!1)}}},[s==null?void 0:s.id,g,x]);o.useEffect(()=>{k([]),I(0),E(!0)},[p]),o.useEffect(()=>{g.size>0&&x.length===0&&j&&!S&&F(0,!0)},[g.size]);const W=()=>{const t=J+1;I(t),F(t)},X=t=>new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"});if(Q||V)return e.jsx(ne,{});if(!s)return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(B,{}),e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx("p",{className:"text-muted-foreground",children:"Category not found"})}),e.jsx(H,{})]});const P=s.count||(l==null?void 0:l.length)||0,u=ie(),b=`${u}/${s.slug}`,N=s,v=N.meta_title||`${s.name} — AIM`,w=N.meta_description||`Explore the latest ${s.name} articles, news, and insights from AIM. Stay updated with cutting-edge coverage.`;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(re,{items:[{name:"Home",url:u},{name:s.name,url:b}]}),e.jsxs(Z,{children:[e.jsx("title",{children:v}),e.jsx("meta",{name:"description",content:w}),e.jsx("meta",{name:"keywords",content:`${s.name}, AI news, data science, technology articles, ${s.name.toLowerCase()} insights`}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:url",content:b}),e.jsx("meta",{property:"og:title",content:v}),e.jsx("meta",{property:"og:description",content:w}),e.jsx("meta",{property:"og:image",content:K(null,u)}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:v}),e.jsx("meta",{name:"twitter:description",content:w}),e.jsx("meta",{name:"twitter:image",content:K(null,u)}),e.jsx("link",{rel:"canonical",href:b}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"CollectionPage",name:v,description:w,url:b,publisher:{"@type":"Organization",name:"AIM",url:u},numberOfItems:P})})]}),e.jsx(B,{}),e.jsxs("main",{children:[e.jsxs("section",{className:"page-container py-8",children:[e.jsxs(G.div,{className:"mb-8 border-b-2 border-foreground pb-4",initial:{opacity:0,y:20}
19,animate:{opacity:1,y:0},transition:{duration:.4},children:[e.jsx("h1",{className:"font-serif text-3xl md:text-4xl font-bold text-foreground mb-1",children:s.name}),N.description&&e.jsx("p",{className:"font-serif text-base md:text-lg text-foreground/80 mt-2 max-w-3xl leading-relaxed",children:N.description}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:[P," ",P===1?"article":"articles"]})]}),i&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 lg:gap-0",children:[e.jsx("div",{className:"lg:col-span-2 lg:pr-6 lg:border-r border-border",children:e.jsx("article",{className:"group",children:e.jsxs(h,{to:`/${i.slug||i.id}`,className:"block",children:[i.image_url&&e.jsx("div",{className:"overflow-hidden mb-4",children:e.jsx(f,{src:i.image_url,alt:i.title,width:900,height:500,className:"w-full aspect-[16/9] object-cover transition-transform duration-500 group-hover:scale-[1.02]",sizes:"(max-width: 768px) 100vw, 66vw",loading:"eager"})}),i.satirical_take&&e.jsx("span",{className:"inline-block text-[11px] font-semibold tracking-[0.1em] uppercase text-accent mb-2 italic",children:i.satirical_take}),e.jsx("h2",{className:"font-serif text-[28px] md:text-[36px] leading-[1.1] text-foreground mb-3 tracking-[-0.02em] group-hover:text-muted-foreground/80 transition-colors font-medium",children:i.title}),e.jsx("p",{className:"text-[16px] md:text-[18px] leading-[1.5] text-muted-foreground mb-3 max-w-[90%]",children:i.excerpt}),e.jsxs("div",{className:"flex items-center gap-3 text-[12px] text-muted-foreground/60",children:[((D=i.authors)==null?void 0:D.name)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-medium",children:i.authors.name}),e.jsx("span",{children:"•"})]}),e.jsxs("span",{className:"uppercase tracking-[0.05em]",children:[((U=i.read_time)==null?void 0:U.replace(" read",""))||"5 min"," read"]})]})]})})}),e.jsxs("div",{className:"lg:pl-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("h3",{className:"text-[13px] font-bold tracking-[0.15em] uppercase text-foreground",children:"Latest"}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx("div",{className:"space-y-0",children:q.map((t,a)=>{var r;return e.jsxs("article",{className:"group animate-fade-in",style:{animationDelay:`${a*80}ms`},children:[e.jsx(h,{to:`/${t.slug||t.id}`,className:"block py-4 transition-colors hover:bg-muted/30 -mx-3 px-3",children:e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[t.satirical_take&&e.jsx("span",{className:"inline-block text-[10px] font-semibold tracking-[0.1em] uppercase text-accent mb-1.5",children:t.satirical_take}),e.jsx("h4",{className:"font-serif text-[14px] md:text-[15px] leading-[1.3] text-foreground group-hover:text-accent transition-colors font-medium",children:t.title}),e.jsx("div",{className:"flex items-center gap-2 mt-2",children:e.jsxs("span",{className:"text-[10px] uppercase tracking-[0.05em] text-muted-foreground/60",children:[((r=t.read_time)==null?void 0:r.replace(" read",""))||"3 min"," read"]})})]}),t.image_url&&e.jsx("div",{className:"flex-shrink-0 w-[90px] h-[60px] overflow-hidden",children:e.jsx(f,{src:t.image_url,alt:t.title,width:90,height:60,className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-[1.02]",sizes:"90px"})})]})}),a<q.length-1&&e.jsx("div",{className:"border-b border-border/50"})]},t.id)})})]})]})]}),e.jsx("div",{className:"page-container my-8",children:e.jsx(O,{slot:"listing_inline",className:"overflow-hidden"})}),z.length>0&&e.jsx(M,{children:e.jsx("section",{className:"page-container py-10",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:z.map((t,a)=>{var r;return e.jsx("article",{className:"group animate-fade-in",style:{animationDelay:`${a*100}ms`},children:e.jsxs(h,{to:`/${t.slug||t.id}`,className:"block",children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[4/3] mb-4",children:t.image_url&&e.jsx(f,{src:t.image_url,alt:t.title,width:400,height:300,className:"w-full h-full object-cover group-hover:scale-[1.02] transition-transform duration-500",sizes:"(max-width: 768px) 100vw, 400px"})}),t.satirical_take&&e.jsx("span",{className:"inline-block px-2.5 py-1 bg-accent text-accent-foreground text-[9px] font-bold tracking-widest uppercase shadow-sm italic mb-2",children:t.satirical_take}),e.jsx("h3",{className:"font-serif font-bold text-[17px] leading-tight text-foreground mb-2 line-clamp-2 group-hover:text-accent transition-colors duration-300",children:t.title}),e.jsx("p",{className:"text-[13px] text-muted-foreground line-clamp-2 leading-relaxed mb-2",children:t.excerpt}),e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[((r=t.authors)==null?void 0:r.name)&&e.jsx("span",{children:t.authors.name}),t.read_time&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-muted-foreground
19/40"}),e.jsx("span",{children:t.read_time})]})]})]})},t.id)})})})}),C.length>0&&e.jsx(M,{children:e.jsx("section",{className:"bg-muted/30 py-12",children:e.jsxs("div",{className:"page-container",children:[e.jsx("div",{className:"flex items-center gap-3 mb-8",children:e.jsxs("h2",{className:"text-lg font-bold text-foreground",children:["Trending in ",s.name]})}),e.jsx("div",{className:"space-y-0",children:C.map((t,a)=>{var r,m;return e.jsx("article",{className:"border-b border-border last:border-0 group",children:e.jsxs(h,{to:`/${t.slug||t.id}`,className:"flex gap-6 py-5",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("span",{className:"font-serif text-4xl font-bold text-muted-foreground/30",children:(a+1).toString().padStart(2,"0")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-serif font-bold text-lg leading-tight text-foreground mb-2 group-hover:text-accent transition-colors",children:t.title}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-2",children:t.excerpt}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[((r=t.authors)==null?void 0:r.name)&&e.jsx("span",{children:t.authors.name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:X(t.published_at||t.created_at)}),e.jsx("span",{children:"•"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ee,{className:"h-3 w-3"}),((m=t.view_count)==null?void 0:m.toLocaleString())||0," views"]})]})]}),t.image_url&&e.jsx("div",{className:"flex-shrink-0 w-24 h-16 overflow-hidden hidden sm:block",children:e.jsx(f,{src:t.image_url,alt:t.title,width:96,height:64,className:"w-full h-full object-cover object-center group-hover:scale-105 transition-transform duration-300",sizes:"96px"})})]})},t.id)})})]})})}),e.jsx("div",{className:"page-container my-10",children:e.jsx(O,{slot:"listing_inline",className:"overflow-hidden"})}),x.length>0&&e.jsx(M,{children:e.jsxs("section",{className:"page-container py-12",children:[e.jsx("div",{className:"flex items-center justify-between mb-8",children:e.jsx("h2",{className:"text-2xl md:text-3xl font-serif font-bold text-foreground",children:"More Stories"})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8",children:x.map((t,a)=>{var r;return e.jsx("article",{className:"group animate-fade-in",style:{animationDelay:`${a%y*50}ms`},children:e.jsxs(h,{to:`/${t.slug||t.id}`,className:"block",children:[t.image_url&&e.jsx("div",{className:"overflow-hidden bg-muted aspect-[16/10] mb-4",children:e.jsx(f,{src:t.image_url,alt:t.title,width:500,height:312,className:"w-full h-full object-cover group-hover:scale-[1.02] transition-transform duration-500",sizes:"(max-width: 768px) 100vw, 33vw"})}),t.satirical_take&&e.jsx("span",{className:"text-[11px] font-bold tracking-widest uppercase text-accent mb-2 block",children:t.satirical_take}),e.jsx("h3",{className:"font-serif font-bold text-lg leading-tight text-foreground mb-2 line-clamp-2 group-hover:text-accent transition-colors",children:t.title}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 leading-relaxed mb-3",children:t.excerpt}),e.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[((r=t.authors)==null?void 0:r.name)&&e.jsx("span",{className:"font-medium",children:t.authors.name}),t.read_time&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-muted-foreground/40"}),e.jsx("span",{children:t.read_time})]})]})]})},t.id)})}),e.jsx(G.div,{className:"flex justify-center mt-10",initial:{opacity:0}
19,animate:{opacity:1},transition:{delay:.3},children:e.jsx(te,{variant:"outline",size:"lg",onClick:W,disabled:!j||S,className:`px-8 group transition-all ${j?"":"opacity-50 cursor-not-allowed"}`,children:S?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading..."]}):j?e.jsxs(e.Fragment,{children:["Load More",e.jsx(ae,{className:"ml-2 h-4 w-4 group-hover:translate-x-0.5 transition-transform"})]}):"No More Articles"})})]})})]}),e.jsx(H,{})]})};export{je 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.