PageSourceSearch

https://analyticsindiamag.com/assets/Following-DIJzrTA-.js

js analyticsindiamag.com collected 2026-09-24 08:26:55 UTC 8,495 bytes, 29 lines download raw bytes

1import{u as L,e as $,a as C,r as N,U as w,s as c,j as e,L as y,H as M,am as b,G as m,B as S,o as i,d as E,Q as k,O as I}from"./index-KSWbwNeY.js";import v from"./Footer-DPSMpmUX.js";import{U as Y}from"./user-minus-jgLnIJNk.js";import{C as z}from"./clock-CzRotAbS.js";import{f as B}from"./format-hhvI2L0z.js";import"./twitter-yEUqfNJX.js";import"./linkedin-B1bA0DJP.js";import"./youtube-CwivUiPT.js";import"./facebook-DahhNxAJ.js";import"./en-US-BOoww7nS.js";const _=(s,o=64)=>s?I(s)?k(s,{width:o,quality:70}):s:"",V=()=>{const{user:s,loading:o}=L(),u=$(),{toast:x}=C(),[h,g]=N.useState(null);N.useEffect(()=>{!o&&!s&&u("/auth",{state:{from:"/following"}})},[s,o,u]);const{data:t,isLoading:F,refetch:U}=w({queryKey:["followed-authors",s==null?void 0:s.id],queryFn:async()=>{if(!s)return[];const{data:r,error:l}=await c.from("author_follows").select(`
2          author_id,
3          authors:author_id (
4            id,
5            slug,
6            name,
7            image_url,
8            role,
9            bio
10          )
11        `).eq("user_id",s.id);if(l)throw l;return(r==null?void 0:r.map(a=>a.authors).filter(Boolean))||[]},enabled:!!s}),{data:d,isLoading:q}=w({queryKey:["following-feed",t==null?void 0:t.map(r=>r.id)],queryFn:async()=>{if(!t||t.length===0)return[];const r=t.map(n=>n.id),{data:l,error:a}=await c.from("posts").select(`
12          id,
13          title,
14          slug,
15          excerpt,
16          image_url,
17          created_at,
18          read_time,
19          author:authors!posts_author_id_fkey (
20            id,
21            slug,
22            name,
23            image_url
24          ),
25          category:categories!posts_category_id_fkey (
26            name,
27            slug
28          )
29        `).in("author_id",r).eq("published",!0).order("created_at",{ascending:!1}).limit(20);if(a)throw a;return l||[]},enabled:!!t&&t.length>0}),A=async(r,l)=>{if(s){g(r);try{const{error:a}=await c.from("author_follows").delete().eq("user_id",s.id).eq("author_id",r);if(a)throw a;x({title:"Unfollowed",description:`You are no longer following ${l}`}),U()}catch{x({variant:"destructive",title:"Error",description:"Failed to unfollow author"})}finally{g(null)}}};return o?e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("main",{className:"max-w-7xl mx-auto px-4 py-12",children:e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(y,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}),e.jsx(v,{})]}):s?e.jsxs(e.Fragment,{children:[e.jsxs(M,{children:[e.jsx("title",{children:"Following - AIM"}),e.jsx("meta",{name:"description",content:"Your personalized feed from authors you follow"}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]}),e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsxs("main",{className:"max-w-7xl mx-auto px-4 py-8 md:py-12",children:[e.jsxs("div",{className:"mb-8 md:mb-12",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(b,{className:"h-6 w-6 text-primary"}),e.jsx("h1",{className:"text-2xl md:text-3xl font-bold text-foreground",children:"Following"})]}),e.jsx("p",{className:"text-muted-foreground",children:"Stay updated with the latest articles from your favorite authors"})]}),F?e.jsxs("div",{className:"space-y-8",children:[e.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4",children:[1,2,3,4].map(r=>e.jsx(m,{className:"w-32 h-40 flex-shrink-0 rounded-xl"},r))}),e.jsx("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3,4,5,6].map(r=>e.jsx(m,{className:"h-80 rounded-xl"},r))})]}):!t||t.length===0?e.jsxs("div",{className:"text-center py-16 px-4",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-20 h-20 rounded-full bg-muted mb-6",children:e.jsx(b,{className:"h-10 w-10 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-3",children:"No authors followed yet"}),e.jsx("p",{className:"text-muted-foreground mb-6 max-w-md mx-auto",children:"Follow your favorite authors to get personalized updates when they publish new articles"}),e.jsx(S,{asChild:!0,children:e.jsxs(i,{to:"/authors",children:["Discover Authors",e.jsx(E,{className:"ml-2 h-4 w-4"})]})})]}):e.jsxs("div",{className:"space-y-10",children:[e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-4 text-foreground",children:"Authors You Follow"}),e.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4 scrollbar-hide",children:t.map(r=>e.jsxs("div",{className:"flex-shrink-0 w-36 group",children:[e.jsxs("div",{className:"relative",children:[e.jsx(i,{to:`/author/${r.slug||r.id}`,children:e.jsx("div",{className:"w-20 h-20 mx-auto rounded-full overflow-hidden border-2 border-primary/20 group-hover:border-primary transition-colors",children:r.image_url?e.jsx("img",{src:_(r.image_url,80),alt:r.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-primary/20 to-primary/40 flex items-center justify-center",children:e.jsx("span",{className:"text-2xl font-bold text-primary",children:r.name.charAt(0)})})})}),e.jsx("button",{onClick:()=>A(r.id,r.name),disabled:h===r.id,className:"absolute -top-1 -right-1 p-1.5 bg-destructive/90 hover:bg-destructive text-destructive-foreground rounded-full opacity-0 group-hover:opacity-100 transition-opacity shadow-sm",title:"Unfollow",children:h===r.id?e.jsx(y,{className:"h-3 w-3 animate-spin"}):e.jsx(Y,{className:"h-3 w-3"})})]}),e.jsxs(i,{to:`/author/${r.slug||r.id}`,className:"block text-center mt-2",children:[e.jsx("p",{className:"font-medium text-sm text-foreground truncate group-hover:text-primary transition-colors",children:r.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:r.role})]})]},r.id))})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-6 text-foreground",children:"Latest from Your Feed"}),q?e.jsx("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3,4,5,6].map(r=>e.jsx(m,{className:"h-80 rounded-xl"},r))}):!d||d.length===0?e.jsx("div",{className:"text-center py-12 bg-muted/30 rounded-xl",children:e.jsx("p",{className:"text-muted-foreground",children:"No recent articles from authors you follow"})}):e.jsx("div",{className:"grid gap-6 md:grid-cols-2 lg:grid-cols-3",children:d.map(r=>{var l,a,n,f,j,p;return e.jsxs("article",{className:"group bg-card border border-border rounded-xl overflow-hidden hover:shadow-lg transition-all duration-300",children:[e.jsx(i,{to:`/${r.slug}`,className:"block",children:e.jsx("div",{className:"aspect-[16/10] overflow-hidden bg-muted",children:r.image_url?e.jsx("img",{src:k(r.image_url,{width:400,quality:60}),alt:r.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"}):e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-muted to-muted-foreground
29/20"})})}),e.jsxs("div",{className:"p-5",children:[r.category&&e.jsx(i,{to:`/${r.category.slug}`,className:"text-xs font-semibold uppercase tracking-wide text-primary hover:underline",children:r.category.name}),e.jsx(i,{to:`/${r.slug}`,children:e.jsx("h3",{className:"mt-2 text-lg font-bold text-foreground line-clamp-2 group-hover:text-primary transition-colors",children:r.title})}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground line-clamp-2",children:r.excerpt}),e.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[(l=r.author)!=null&&l.image_url?e.jsx("img",{src:_(r.author.image_url,64),alt:r.author.name,className:"w-8 h-8 rounded-full object-cover"}):e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:((n=(a=r.author)==null?void 0:a.name)==null?void 0:n.charAt(0))||"A"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(i,{to:`/author/${((f=r.author)==null?void 0:f.slug)||((j=r.author)==null?void 0:j.id)}`,className:"text-sm font-medium text-foreground hover:text-primary transition-colors truncate block",children:(p=r.author)==null?void 0:p.name}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("time",{children:B(new Date(r.created_at),"MMM d, yyyy")}),r.read_time&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"h-3 w-3"}),r.read_time]})]})]})]})]})]})]},r.id)})})]})]})]}),e.jsx(v,{})]})]}):null};export{V 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.