1import{j as e,H as V}from"./index-A5apO8sf.js";import{L as _,r as i,i as E}from"./vendor-react-DXfu0YkJ.js";import{O as d}from"./OptimizedImage-6JiG88Oe.js";import{B as p}from"./Skeletons-wgbYJ8M6.js";import"./vendor-pdf-v-sEuCgt.js";import"./vendor-ui--7kLNIgQ.js";import"./vendor-charts-odGm-fv0.js";import"./vendor-icons-DAn0tkMA.js";import"./vendor-supabase-BVvKO2AB.js";const S=({post:t,onClick:l})=>{const o=`/blog/${t.slug||t.id}`;return e.jsxs(_,{to:o,className:"block bg-white p-6 sm:p-8 rounded-[15px] shadow-lg grid lg:grid-cols-2 gap-8 lg:gap-12 items-center cursor-pointer transition-transform hover:scale-[1.01] duration-300 group",onClick:()=>l&&l(t),children:[e.jsx("div",{className:"relative aspect-video rounded-[15px] overflow-hidden shadow-md",children:e.jsx(d,{src:t.imageUrl,alt:t.title,className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"})}),e.jsxs("div",{className:"flex flex-col justify-center",children:[e.jsx("span",{className:"inline-block bg-brand-purple-light text-brand-purple font-semibold px-4 py-1.5 rounded-full text-sm mb-4 self-start",children:t.category}),e.jsx("h2",{className:"text-3xl md:text-4xl font-extrabold text-gray-900 leading-tight mb-4 group-hover:text-brand-purple transition-colors",children:t.title}),e.jsx("p",{className:"text-gray-600 text-lg leading-relaxed mb-6 line-clamp-3",children:t.excerpt}),e.jsxs("div",{className:"flex items-center space-x-4 mb-8",children:[e.jsx(d,{src:t.authorAvatar,alt:t.author,width:48,height:48,className:"w-12 h-12 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-gray-800",children:t.author}),e.jsx("p",{className:"text-sm text-gray-500",children:t.date})]})]}),e.jsx("div",{className:"self-start bg-brand-purple text-white font-bold py-3 px-8 rounded-lg hover:bg-brand-purple-dark transition-colors shadow-md transform hover:scale-105 inline-block text-center",children:"Read Article"})]})]})},B=({post:t,onClick:l,basePath:o="/blog"})=>{const c=`${o}/${t.slug||t.id}`;return e.jsxs(_,{to:c,className:"bg-white rounded-[15px] shadow-md hover:shadow-2xl transition-all duration-300 flex flex-col overflow-hidden group border border-gray-200/80 cursor-pointer h-full",onClick:n=>{l&&l(t)},children:[e.jsxs("div",{className:"relative overflow-hidden",children:[e.jsx(d,{src:t.imageUrl,alt:t.title,className:"w-full aspect-video object-cover group-hover:scale-105 transition-transform duration-300"}),e.jsx("span",{className:"absolute top-4 left-4 bg-brand-purple text-white font-bold px-3 py-1 rounded-full text-[10px] uppercase tracking-wider",children:t.category})]}),e.jsxs("div",{className:"p-5 flex flex-col flex-grow",children:[e.jsx("h3",{className:"text-lg font-bold text-gray-800 mb-3 group-hover:text-brand-purple transition-colors leading-tight line-clamp-2 min-h-[2.5rem] sm:min-h-[3rem]",children:t.title}),e.jsx("p",{className:"text-gray-500 text-sm mb-5 line-clamp-2 leading-relaxed",children:t.excerpt}),e.jsxs("div",{className:"mt-auto flex items-center space-x-3 pt-4 border-t border-gray-100",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-purple-50 border border-purple-100 overflow-hidden flex-shrink-0",children:e.jsx(d,{src:t.authorAvatar||"https://res.cloudinary.com/dn93gd6yw/image/upload/f_auto,q_auto/v1762151396/weversity-icon_wzmplh.png",alt:t.author,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-bold text-gray-800 text-xs truncate",children:t.author}),e.jsx("p",{className:"text-[10px] font-medium text-gray-400",children:t.date})]})]})]})]})},N=6,D=()=>{const[t,l]=i.useState([]),[o,c]=i.useState(N),[n,m]=i.useState(!0),k=E(),g=i.useCallback(async()=>{t.length===0&&m(!0);const{data:r,error:f}=await window.supabase.from("blogs").select("id, title, slug, category, image_url, excerpt, author_id, created_at, scheduled_at").eq("is_published",!0).is("center_id",null);if(f){console.error("Error fetching posts:",f),m(!1);return}if(r){const y=[...r].sort((s,a)=>{const x=new Date(s.scheduled_at||s.created_at).getTime();return new Date(a.scheduled_at||a.created_at).getTime()-x}),w=[...new Set(y.map(s=>s.author_id).filter(s=>s))];let j={};if(w.length>0){const{data:s}=await window.supabase.from("profiles").select("id, first_name, last_name, avatar_url").in("id",w);
1s&&s.forEach(a=>{j[a.id]=a})}const P=y.map(s=>{const a=j[s.author_id],x=a?`${a.first_name||""} ${a.last_name||""}`.trim():"WeVersity Team",v=(a==null?void 0:a.avatar_url)||"https://res.cloudinary.com/dn93gd6yw/image/upload/f_auto,q_auto/v1762151396/weversity-icon_wzmplh.png";return{id:s.id,title:s.title,imageUrl:s.image_url||`https://picsum.photos/seed/${s.id}/800/600`,category:s.category||"General",date:new Date(s.scheduled_at||s.created_at).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"}),author:x||"WeVersity Team",authorAvatar:v,excerpt:s.excerpt||"",comments:0,slug:s.slug}});l(P)}m(!1)},[]);i.useEffect(()=>{g();const r=window.supabase.channel("public:blogs").on("postgres_changes",{event:"*",schema:"public",table:"blogs",filter:"is_published=eq.true"},()=>{g()}).subscribe();return()=>{window.supabase.removeChannel(r)}},[g]),i.useEffect(()=>{n||setTimeout(()=>{},500)},[n]);const u=t[0],h=t.slice(1),W=h.slice(0,o),H=()=>{c(r=>r+N)},b=r=>{window.scrollTo({top:0,behavior:"smooth"}),k(`/blog/${r.slug||r.id}`)};return e.jsxs("div",{className:"bg-gray-50 min-h-screen",children:[e.jsxs(V,{defer:!1,children:[e.jsx("title",{children:"Knowledge Hub | WeVersity Blog"}),e.jsx("meta",{name:"description",content:"Explore the latest articles, tutorials, and insights on WeVersity's Knowledge Hub."}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:title",content:"Knowledge Hub | WeVersity Blog"}),e.jsx("meta",{property:"og:description",content:"Explore the latest articles, tutorials, and insights on WeVersity's Knowledge Hub."}),e.jsx("meta",{property:"og:image",content:"https://res.cloudinary.com/dn93gd6yw/image/upload/f_auto,q_auto/v1762151396/weversity-logo_p9owli.png"}),e.jsx("meta",{property:"og:site_name",content:"WeVersity"}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"Blog",name:"Knowledge Hub | WeVersity Blog",description:"Explore the latest articles, tutorials, and insights on WeVersity's Knowledge Hub.",url:"https://weversity.org/blogs",publisher:{"@type":"Organization",name:"WeVersity",logo:{"@type":"ImageObject",url:"https://res.cloudinary.com/dn93gd6yw/image/upload/f_auto,q_auto/v1762151396/weversity-logo_p9owli.png"}}})}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:site",content:"@weversityo"}),e.jsx("meta",{name:"twitter:title",content:"Knowledge Hub | WeVersity Blog"}),e.jsx("meta",{name:"twitter:description",content:"Explore the latest articles, tutorials, and insights on WeVersity's Knowledge Hub."}),e.jsx("meta",{name:"twitter:image",content:"https://res.cloudinary.com/dn93gd6yw/image/upload/f_auto,q_auto/v1762151396/weversity-logo_p9owli.png"})]}),e.jsxs("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8 py-10",children:[e.jsx("h1",{className:"sr-only",children:"WeVersity Knowledge Hub"}),n&&t.length===0?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-[400px] bg-gray-200 rounded-[15px] animate-pulse mb-10"}),e.jsx("div",{className:"my-10 h-64 bg-gray-200 rounded-[15px] animate-pulse"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8",children:[e.jsx(p,{}),e.jsx(p,{}),e.jsx(p,{})]})]}):e.jsxs(e.Fragment,{children:[u?e.jsx(S,{post:u,onClick:b}):e.jsxs("div",{className:"text-center py-20 bg-white rounded-[15px] shadow-sm border border-gray-200",children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-700",children:"Welcome to Knowledge Hub"}),e.jsx("p",{className:"text-gray-500 mt-2",children:"Stay tuned! Amazing articles are coming soon."})]}),e.jsx("div",{className:"my-10"}),e.jsxs("div",{className:"mb-12",children:[e.jsx("h2",{className:"text-3xl font-bold text-gray-900",children:"Latest Articles"}),e.jsx("div",{className:"w-16 h-1 bg-brand-purple mt-2 rounded-full"})]}),h.length>0?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8",children:W.map(r=>e.jsx(B,{post:r,onClick:b},r.id))}):u&&e.jsx("div",{className:"text-center py-10 text-gray-500",children:"No additional articles found yet."}),o<h.length&&e.jsx("div",{className:"text-center mt-16",children:e.jsx("button",{onClick:H,className:"bg-white border-2 border-brand-purple text-brand-purple font-bold py-3 px-10 rounded-lg hover:bg-brand-purple hover:text-white transition-all duration-300 shadow-md",children:"Load More Articles"})})]})]})]})};export{D 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.