import{j as e,H as t,J as s,K as r,c as a,v as l,r as i,b as o,N as n}from"./ui-0c1fdf09.js";import{u as d,P as c,H as g}from"./index-c49ab0da.js";import{r as m,L as x,u as h,d as p}from"./vendor-d03f97b3.js";import{g as u}from"./contentful-8203f2b3.js";import y from"./AnimatedSection-83e11685.js";import{f}from"./format-6bc33007.js";import"./contentful-28d081df.js";import"./isPlainObject-bf45ffc7.js";const b=()=>{const[r,a]=m.useState([]),[l,i]=m.useState(!0),[o,n]=m.useState(null),[c,g]=m.useState(""),[x,h]=m.useState(null),[p,y]=m.useState(""),{isDarkMode:f}=d(),b=[...new Set(r.flatMap((e=>e.fields.categories||[])))];m.useEffect((()=>{(async()=>{i(!0);try{y("Fetching posts..."),console.log("Fetching blog posts..."),console.log("Contentful credentials:",{spaceId:"Found",accessToken:"Found"});const e=await u();if(console.log("Fetched posts:",e),y((t=>t+`\nFetched ${e.length} posts`)),0===e.length)y((e=>e+"\nNo posts found. Check Contentful setup."));else{const t=e[0];y((e=>e+`\nFirst post: ${t.fields.title}`)),console.log("First post:",t)}a(e)}catch(e){console.error("Error fetching blog posts:",e),n("Failed to load blog posts. Please try again later."),y((t=>t+`\nError: ${e instanceof Error?e.message:"Unknown error"}`))}finally{i(!1)}})()}),[]);const w=r.filter((e=>{const t=""===c.trim()||e.fields.title.toLowerCase().includes(c.toLowerCase())||e.fields.excerpt&&e.fields.excerpt.toLowerCase().includes(c.toLowerCase()),s=null===x||e.fields.categories&&e.fields.categories.includes(x);return t&&s}));return l?e.jsxs("div",{className:"min-h-[400px] flex flex-col items-center justify-center",children:[e.jsx("div",{className:"w-10 h-10 border-4 border-blue-500 border-t-transparent rounded-full animate-spin mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-300",children:"Loading blog posts..."})]}):o?e.jsx("div",{className:"min-h-[400px] flex items-center justify-center",children:e.jsxs("div",{className:"text-center p-8 max-w-md bg-white dark:bg-gray-800 rounded-xl shadow-md",children:[e.jsx("div",{className:"text-red-500 text-5xl mb-4",children:"😕"}),e.jsx("h3",{className:"text-xl font-bold text-gray-900 dark:text-white mb-2",children:"Blog temporarily unavailable"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-300 mb-4",children:o}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mb-4 text-left whitespace-pre-wrap",children:p}),e.jsxs("div",{className:"flex justify-center gap-3",children:[e.jsx("button",{onClick:()=>window.location.reload(),className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors",children:"Try again"}),e.jsx("a",{href:"/",className:"px-4 py-2 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-200 rounded-lg transition-colors",children:"Return home"})]})]})}):0===r.length?e.jsx("div",{className:"min-h-[400px] flex flex-col items-center justify-center py-12 px-4",children:e.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/30 p-6 rounded-lg border border-yellow-200 dark:border-yellow-800 max-w-lg",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx(t,{className:"h-6 w-6 mr-3 mt-0.5 flex-shrink-0 text-yellow-600 dark:text-yellow-400"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-lg mb-2 text-yellow-800 dark:text-yellow-200",children:"No blog posts found"}),e.jsx("p",{className:"mb-3 text-yellow-700 dark:text-yellow-300",children:"We couldn't find any blog posts in your Contentful space. Please check your Contentful setup."}),e.jsx("div",{className:"bg-white dark:bg-gray-800 p-3 rounded text-xs font-mono text-gray-700 dark:text-gray-300 mb-3 max-h-48 overflow-auto whitespace-pre-wrap",children:p||"No debug information available"}),e.jsx("p",{className:"text-sm text-yellow-700 dark:text-yellow-300",children:"Make sure you've created blog content in Contentful and that your API credentials are correct."})]})]})})}):e.jsxs("div",{children:[e.jsxs("div",{className:"mb-8 space-y-4",children:[e.jsxs("div",{className:"relative rounded-lg overflow-hidden border "+(f?"border-gray-700":"border-gray-200"),children:[e.jsx("input",{type:"text",placeholder:"Search articles...",value:c,onChange:e=>g(e.target.value),className:`w-full px-4 py-3 pl-10 ${f?"bg-gray-800 text-white placeholder-gray-400":"bg-white text-gray-800 placeholder-gray-500"} focus:outline-none focus:ring-2 focus:ring-blue-500`}),e.jsx(s,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400",size:18})]}),b.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 mt-4",children:[b.map((t=>e.jsx("button",{onClick:()=>(e=>{h((t=>t===e?null:e))})(t),className:"px-3 py-1 text-sm rounded-full transition-colors "+(x===t?"bg-blue-600 text-white":f?"bg-gray-700 text-gray-300 hover:bg-gray-600":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:t},t))),x&&e.jsx("button",{onClick:()=>h(null),className:"px-3 py-1 text-sm rounded-full "+(f?"bg-gray-800 text-gray-400 hover:bg-gray-700":"bg-gray-50 text-gray-500 hover:bg-gray-100"),children:"Clear filter"})]})]}),0===w.length&&e.jsxs("div",{className:"min-h-[200px] flex flex-col items-center justify-center text-center p-8",children:[e.jsx("div",{className:"text-3xl mb-4",children:"🔍"}),e.jsx("h3",{className:"text-xl font-semibold mb-2 "+(f?"text-white":"text-gray-900"),children:"No matching articles found"}),e.jsx("p",{className:"max-w-md mb-4 "+(f?"text-gray-300":"text-gray-600"),children:"Try adjusting your search or filters to find what you're looking for."}),c&&e.jsx("button",{onClick:()=>g(""),className:"px-4 py-2 rounded-lg mr-2 "+(f?"bg-gray-800 text-gray-200 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:"Clear search"}),x&&e.jsx("button",{onClick:()=>h(null),className:"px-4 py-2 rounded-lg "+(f?"bg-gray-800 text-gray-200 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:"Clear category filter"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8",children:w.map(((t,s)=>e.jsx(j,{post:t,index:s},t.sys.id)))})]})},j=({post:t,index:s})=>{var n,c,g,m,h,p,u,b;const{isDarkMode:j}=d(),w=t.fields.publishedDate?f(new Date(t.fields.publishedDate),"MMM d, yyyy"):f(new Date(t.sys.createdAt),"MMM d, yyyy"),v=(null==(g=null==(c=null==(n=t.fields.image)?void 0:n.fields)?void 0:c.file)?void 0:g.url)?`https:${t.fields.image.fields.file.url}?fm=webp&w=600&h=400&fit=fill`:`https://images.unsplash.com/photo-${15e11+s}?fm=webp&w=600&h=400&fit=fill`,N=(()=>{if(t.fields.excerpt)return t.fields.excerpt;if("string"==typeof t.fields.body)return t.fields.body.substring(0,150)+"...";if(t.fields.body&&"object"==typeof t.fields.body)try{const e=t.fields.body;if(e.content)for(const t of e.content)if("paragraph"===t.nodeType&&t.content){const e=t.content.filter((e=>"text"===e.nodeType)).map((e=>e.value));if(e.length>0){const t=e.join(" ");return t.length>150?t.substring(0,150)+"...":t}}}catch(e){console.log("Error extracting excerpt from body:",e)}return"Read this article on our blog..."})(),k=(()=>{let e=0;if("string"==typeof t.fields.body)e=t.fields.body.split(/\s+/).length;else if(t.fields.body&&"object"==typeof t.fields.body)try{const s=t.fields.body,r=e=>e?"text"===e.nodeType&&e.value?e.value.split(/\s+/).length:e.content&&Array.isArray(e.content)?e.content.reduce(((e,t)=>e+r(t)),0):0:0;e=r(s)}catch(s){console.log("Error counting words:",s),e=500}return Math.max(1,Math.ceil(e/200))})();return e.jsx(y,{className:"group h-full rounded-xl overflow-hidden shadow-sm transition-shadow hover:shadow-md "+(j?"bg-gray-800 shadow-gray-900":"bg-white shadow-gray-200"),delay:.1*s,children:e.jsxs(x,{to:t.fields.customUrl?`/blog/${t.fields.customUrl}`:t.fields.slug?`/blog/${t.fields.slug}`:`/blog/${t.sys.id}`,className:"block h-full",children:[e.jsxs("div",{className:"relative h-48 overflow-hidden",children:[e.jsx("img",{src:v,alt:t.fields.title,className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105",loading:"lazy",width:"600",height:"400"}),t.fields.categories&&t.fields.categories.length>0&&e.jsx("div",{className:"absolute top-3 left-3",children:e.jsxs("div",{className:"inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium "+(j?"bg-blue-900/80 text-blue-200":"bg-blue-100 text-blue-800"),children:[e.jsx(r,{size:12,className:"mr-1"}),t.fields.categories[0]]})})]}),e.jsxs("div",{className:"p-5",children:[e.jsx("h3",{className:`text-xl font-bold mb-2 ${j?"text-white":"text-gray-900"} group-hover:text-blue-600 transition-colors`,children:t.fields.title}),N&&e.jsx("p",{className:"mb-4 line-clamp-3 "+(j?"text-gray-300":"text-gray-600"),children:N}),e.jsxs("div",{className:"flex justify-between items-center pt-2",children:[e.jsxs("div",{className:"flex items-center text-sm "+(j?"text-gray-400":"text-gray-500"),children:[e.jsx(a,{size:14,className:"mr-1"}),e.jsx("span",{children:w})]}),e.jsxs("div",{className:"flex items-center text-sm "+(j?"text-gray-400":"text-gray-500"),children:[e.jsx(l,{size:14,className:"mr-1"}),e.jsxs("span",{children:[k," min read"]})]})]}),t.fields.author&&e.jsxs("div",{className:"flex items-center mt-4",children:[(null==(u=null==(p=null==(h=null==(m=t.fields.author.fields)?void 0:m.avatar)?void 0:h.fields)?void 0:p.file)?void 0:u.url)?e.jsx("img",{src:`https:${t.fields.author.fields.avatar.fields.file.url}`,alt:t.fields.author.fields.name||"Author",className:"w-6 h-6 rounded-full object-cover mr-2 border border-gray-200 dark:border-gray-700",width:"24",height:"24",loading:"lazy"}):e.jsx("div",{className:"w-6 h-6 rounded-full mr-2 flex items-center justify-center "+(j?"bg-gray-700 text-gray-400":"bg-gray-200 text-gray-600"),children:e.jsx(i,{size:12})}),e.jsx("span",{className:"text-xs font-medium "+(j?"text-gray-300":"text-gray-700"),children:(null==(b=t.fields.author.fields)?void 0:b.name)||("4teKNzPkzDPysbkdacG8D0"===t.sys.id?"Enri Zhulati":"Author")})]})]}),e.jsxs("div",{className:"px-5 pb-5 pt-2 border-t flex justify-between items-center "+(j?"border-gray-700":"border-gray-100"),children:[e.jsx("span",{className:`text-sm font-medium ${j?"text-blue-400":"text-blue-600"} group-hover:underline`,children:"Read more"}),e.jsx(o,{size:16,className:j?"text-blue-400":"text-blue-600"})]})]})})},w=()=>{const t=h(),s=p(),{isDarkMode:r}=d(),a=new URLSearchParams(t.search).get("category"),l=a?`${a} Articles - Enri Zhulati Blog`:"Expert SEO & Web Strategy Insights – Blog",i=a?`Read expert articles about ${a} from digital growth strategist Enri Zhulati.`:"Discover actionable tips on SEO, content marketing, and web design to grow your business.",o=`https://enrizhulati.com${t.pathname}${t.search}`;return e.jsxs(c,{children:[e.jsxs(g,{children:[e.jsx("title",{children:l}),e.jsx("meta",{name:"description",content:i}),e.jsx("meta",{name:"keywords",content:"SEO, content marketing, web design, digital marketing, website optimization, lead generation"}),e.jsx("link",{rel:"canonical",href:o}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:title",content:l}),e.jsx("meta",{property:"og:description",content:i}),e.jsx("meta",{property:"og:url",content:o}),e.jsx("meta",{property:"og:site_name",content:"Enri Zhulati"}),e.jsx("meta",{property:"og:image",content:"https://enrizhulati.com/blog-social-image.jpg"}),e.jsx("meta",{property:"og:image:width",content:"1200"}),e.jsx("meta",{property:"og:image:height",content:"630"}),e.jsx("meta",{property:"og:locale",content:"en_US"}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:site",content:"@enrizhulati"}),e.jsx("meta",{name:"twitter:creator",content:"@enrizhulati"}),e.jsx("meta",{name:"twitter:title",content:l}),e.jsx("meta",{name:"twitter:description",content:i}),e.jsx("meta",{name:"twitter:image",content:"https://enrizhulati.com/blog-social-image.jpg"}),e.jsx("meta",{name:"robots",content:"index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1"}),e.jsx("meta",{name:"googlebot",content:"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"}),e.jsx("meta",{name:"bingbot",content:"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"Blog",name:"Enri Zhulati Blog",description:"Expert insights on SEO, web design, and digital marketing strategies",url:"https://enrizhulati.com/blog",author:{"@type":"Person",name:"Enri Zhulati",url:"https://enrizhulati.com",sameAs:["https://twitter.com/enrizhulati","https://linkedin.com/in/enrizhulati"]},publisher:{"@type":"Person",name:"Enri Zhulati",logo:{"@type":"ImageObject",url:"https://enrizhulati.com/favicon.svg"}},mainEntityOfPage:{"@type":"WebPage","@id":"https://enrizhulati.com/blog"},keywords:"SEO, content marketing, web design, digital marketing, website optimization, lead generation",inLanguage:"en-US"})})]}),e.jsx("div",{className:"max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-16 sm:py-24",children:e.jsxs(y,{children:[e.jsxs("header",{className:"mb-12 md:mb-16 text-center",children:[e.jsx("h1",{className:"text-4xl sm:text-5xl font-bold mb-4 "+(r?"text-white":"text-gray-900"),children:a?`${a} Articles`:"Blog"}),e.jsx("div",{className:"w-24 h-1 bg-gradient-to-r from-blue-500 to-indigo-500 mx-auto rounded-full mb-6"}),e.jsx("p",{className:"text-lg max-w-2xl mx-auto "+(r?"text-gray-300":"text-gray-600"),children:a?`Articles about ${a.toLowerCase()} and related topics.`:"Insights and ideas to help improve your online presence and digital strategy."}),a&&e.jsxs("button",{onClick:()=>{s("/blog")},className:"mt-4 inline-flex items-center px-3 py-1.5 rounded-full text-sm "+(r?"bg-gray-800 text-gray-300 hover:bg-gray-700":"bg-gray-100 text-gray-700 hover:bg-gray-200"),children:[e.jsx(n,{size:14,className:"mr-1"}),"All articles"]})]}),e.jsx(b,{})]})})]})};export{w as default};
//# sourceMappingURL=Blog-7f094c2c.js.map