PageSourceSearch

https://jkshahclasses.com/assets/BlogPage-CS8Xe_BR.js

js jkshahclasses.com collected 2026-10-02 13:23:14 UTC 7,606 bytes, 1 lines download raw bytes

1var S=(l,c,s)=>new Promise((v,u)=>{var b=i=>{try{d(s.next(i))}catch(n){u(n)}},N=i=>{try{d(s.throw(i))}catch(n){u(n)}},d=i=>i.done?v(i.value):Promise.resolve(i.value).then(b,N);d((s=s.apply(l,c)).next())});import{bW as K,u as O,r,bA as T,j as e,bT as V,Q as j,S as A,an as G,B as w,aS as F,L as M}from"./index-COtfmzs3.js";import{B as X}from"./BlogSidebar-D5rUEf3X.js";function ae(){var P;const[l,c]=K();O();const[s,v]=r.useState([]),[u,b]=r.useState([]),[N,d]=r.useState(!0),[i,n]=r.useState(l.get("search")||""),[L,p]=r.useState(l.get("search")||""),m=l.get("category"),o=l.get("search")||"",[x,C]=r.useState(1),[k,I]=r.useState(!1),[D,_]=r.useState(1),[Y,H]=r.useState(0),f=r.useCallback((a,t,h)=>S(null,null,function*(){var B,E;a===1?d(!0):I(!0);try{const y={page:a,limit:9,search:t};h&&(y.category=h);const g=yield T.getBlogs(y);g.ok&&(v(z=>a===1?g.data.data:[...z,...g.data.data]),_(((B=g.data.pagination)==null?void 0:B.pages)||1),H(((E=g.data.pagination)==null?void 0:E.total)||0))}catch(y){console.error("Failed to fetch blogs",y)}finally{d(!1),I(!1)}}),[]),Q=()=>S(null,null,function*(){try{const a=yield T.getCategories({limit:100,onlyActive:!0});a.ok&&b(a.data.data)}catch(a){console.error("Failed to fetch categories",a)}});r.useEffect(()=>{Q()},[]),r.useEffect(()=>{C(1),f(1,o,m)},[o,m,f]),r.useEffect(()=>{x>1&&f(x,o,m)},[x,f]),r.useEffect(()=>{n(o),p(o)},[o]);const R=()=>{C(a=>a+1)},U=a=>{a.preventDefault();const t=new URLSearchParams(l);i?(t.set("search",i),t.delete("category")):t.delete("search"),t.delete("page"),c(t)},J=a=>{const t=new URLSearchParams(l);a?t.set("search",a):t.delete("search"),t.delete("page"),c(t)},W=a=>{const t=new URLSearchParams;a&&t.set("category",a),c(t),n(""),p("")},$=()=>{c({}),n(""),p("")};return e.jsxs("div",{className:"min-h-screen bg-white pb-20 font-sans",children:[e.jsx(V,{url:"https://jkshahclasses.com/blog"}),e.jsx("div",{className:"bg-white pt-28 pb-16 px-4 border-b border-gray-100",children:e.jsxs("div",{className:"max-w-7xl mx-auto text-center",children:[e.jsxs(j.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},transition:{duration:.6},children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-bold text-gray-900 mb-4 font-serif italic",children:"The JK Shah Journal"}),e.jsx("p",{className:"text-gray-500 text-lg md:text-xl max-w-2xl mx-auto mb-10 font-medium",children:"Expert insights, exam strategies, and the latest from the world of professional education."})]}),e.jsx(j.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{delay:.2,duration:.5},className:"max-w-xl mx-auto relative",children:e.jsx("form",{onSubmit:U,children:e.jsxs("div",{className:"relative group",children:[e.jsx(A,{className:"absolute left-0 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400 group-focus-within:text-primary transition-colors"}),e.jsx(G,{placeholder:"Search stories, ideas, and expertise...",className:"pl-8 pr-4 py-6 bg-transparent border-0 border-b border-gray-200 rounded-none shadow-none focus-visible:ring-0 focus-visible:border-primary text-gray-900 text-lg placeholder:text-gray-400 decoration-none",value:i,onChange:a=>n(a.target.value)}),e.jsx(w,{type:"submit",variant:"ghost",className:"absolute right-0 top-1/2 -translate-y-1/2 text-primary font-bold hover:bg-transparent",children:"Search"})]})})})]})}),e.jsx("div",{className:"max-w-7xl mx-auto px-4 mt-12",children:e.jsxs("div",{className:"flex flex-col lg:flex-row gap-8",children:[e.jsx("div",{className:"flex-1",children:N?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 space-y-4",children:[e.jsx(F,{className:"h-10 w-10 animate-spin text-primary"}),e.jsx("p",{className:"text-gray-500 font-medium",children:"Fetching the latest stories..."})]}):s.length>0?e.jsxs("div",{className:"space-y-12",children:[x===1&&!o&&!m&&s[0]&&e.jsx(j.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.8},className:"mb-16",children:e.jsxs(M,{to:`/blog/${s[0].slug}`,className:"group grid lg:grid-cols-2 gap-8 items-center",children:[e.jsx("div",{className:"relative aspect-[16/10] rounded-2xl overflow-hidden bg-gray-100",children:e.jsx("img",{src:s[0].image,alt:s[0].title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center gap-3 text-xs font-bold uppercase tracking-widest text-primary",children:e.jsx("span",{children:((P=s[0].category)==null?void 0:P.name)||"Featured"})}),e.jsx("h2",{className:"text-3xl md:text-4xl font-bold font-serif text-gray-900 leading-tight group-hover:underline decoration-primary/30 underline-offset-4",children:s[0].title}),e.jsx("div",{className:"text-gray-600 text-lg line-clamp-3 leading-relaxed",dangerouslySetInnerHTML:{__html:s[0].description}}),e.jsx("div",{className:"pt-2",children:e.jsx("p",{className:"text-sm font-serif italic text-gray-500",children:new Date(s[0].createdAt).toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})})})]})]})}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-12",children:s.slice(x===1&&!o&&!m?1:0).map((a,t)=>{var h;return e.jsx(j.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{delay:t*.1,duration:.5},children:e.jsxs(M,{to:`/blog/${a.slug}`,className:"group flex flex-col h-full bg-white rounded-xl overflow-hidden",children:[e.jsx("div",{className:"relative aspect-[16/9] overflow-hidden rounded-xl mb-6",children:e.jsx("img",{src:a.image,alt:a.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center gap-3 text-[10px] font-bold uppercase tracking-widest text-primary",children:e.jsx("span",{children:((h=a.category)==null?void 0:h.name)||"Article"})}),e.jsx("h3",{className:"text-xl font-bold text-gray-900 line-clamp-2 leading-tight font-serif group-hover:text-primary transition-colors",children:a.title}),e.jsx("div",{className:"text-gray-500 text-sm line-clamp-2 leading-relaxed",dangerouslySetInnerHTML:{__html:a.description}}),e.jsx("div",{className:"pt-2",children:e.jsx("span",{className:"text-xs font-serif italic text-gray-400",children:new Date(a.createdAt).toLocaleDateString(void 0,{month:"long",day:"numeric",year:"numeric"})})})]})]})},a._id)})}),x<D&&e.jsx("div",{className:"mt-12 flex justify-center",children:e.jsx(w,{variant:"outline",size:"lg",onClick:R,disabled:k,className:"rounded-full px-10 border-gray-200 hover:bg-primary hover:text-white transition-colors hover:border-transparent font-bold tracking-wide",children:k?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading..."]}):"Load More"})})]}):e.jsx("div",{className:"bg-white rounded-2xl p-20 text-center border border-dashed border-gray-200 shadow-sm",children:e.jsxs("div",{className:"max-w-sm mx-auto",children:[e.jsx("div",{className:"bg-primary/5 rounded-full w-20 h-20 flex items-center justify-center mx-auto mb-6",children:e.jsx(A,{className:"h-10 w-10 text-primary/40"})}),e.jsx("h3",{className:"text-xl font-bold text-gray-900 mb-2",children:"No results found"}),e.jsx("p",{className:"text-gray-500 mb-8",children:"We couldn't find any articles matching your search criteria. Try adjusting your filters."}),e.jsx(w,{variant:"default",className:"rounded-full px-8",onClick:$,children:"Clear all filters"})]})})}),e.jsx(X,{searchQuery:L,setSearchQuery:p,categories:u,selectedCategory:m,setSelectedCategory:W,onSearch:()=>J(L)})]})})]})}export{ae as BlogPage,ae 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.