"use strict";(()=>{var e={};e.id=8342,e.ids=[8342],e.modules={53524:e=>{e.exports=require("@prisma/client")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},9774:(e,t,a)=>{a.r(t),a.d(t,{headerHooks:()=>m,originalPathname:()=>b,patchFetch:()=>v,requestAsyncStorage:()=>p,routeModule:()=>c,serverHooks:()=>g,staticGenerationAsyncStorage:()=>d,staticGenerationBailout:()=>h});var r={};a.r(r),a.d(r,{GET:()=>u});var o=a(95419),s=a(69108),i=a(99678),n=a(78070),l=a(34490);async function u(e){try{let{searchParams:t}=e.nextUrl,a=Math.max(1,parseInt(t.get("page")||"1",10)),r=Math.min(50,Math.max(1,parseInt(t.get("limit")||"12",10))),o=t.get("category"),s=t.get("search"),i=t.get("featured"),u={status:"PUBLISHED"};o&&(u.category={slug:o}),s&&(u.OR=[{titleEn:{contains:s,mode:"insensitive"}},{titleAr:{contains:s,mode:"insensitive"}}]),"true"===i&&(u.featured=!0);let[c,p]=await Promise.all([l.prisma.blogPost.findMany({where:u,skip:(a-1)*r,take:r,orderBy:[{featured:"desc"},{publishedAt:"desc"}],select:{id:!0,slug:!0,titleEn:!0,titleAr:!0,excerptEn:!0,excerptAr:!0,coverImage:!0,featured:!0,viewsCount:!0,readTimeMin:!0,publishedAt:!0,author:{select:{name:!0,image:!0}},category:{select:{slug:!0,nameEn:!0,nameAr:!0,color:!0}}}}),l.prisma.blogPost.count({where:u})]);return n.Z.json({posts:c,total:p,page:a,totalPages:Math.ceil(p/r)},{headers:{"Cache-Control":"public, s-maxage=60, stale-while-revalidate=300"}})}catch(e){return console.error("Error fetching blog posts:",e),n.Z.json({error:"Failed to fetch blog posts"},{status:500})}}let c=new o.AppRouteRouteModule({definition:{kind:s.x.APP_ROUTE,page:"/api/blog/route",pathname:"/api/blog",filename:"route",bundlePath:"app/api/blog/route"},resolvedPagePath:"C:\\test2\\pagecraft-ai\\src\\app\\api\\blog\\route.ts",nextConfigOutput:"standalone",userland:r}),{requestAsyncStorage:p,staticGenerationAsyncStorage:d,serverHooks:g,headerHooks:m,staticGenerationBailout:h}=c,b="/api/blog/route";function v(){return(0,i.patchFetch)({serverHooks:g,staticGenerationAsyncStorage:d})}},34490:(e,t,a)=>{a.d(t,{prisma:()=>o});var r=a(53524);let o=globalThis.prisma??new r.PrismaClient}};var t=require("../../../webpack-runtime.js");t.C(e);var a=e=>t(t.s=e),r=t.X(0,[1638,6206],()=>a(9774));module.exports=r})();