@xexr/blog-platform 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +110 -29
- package/dist/app/blog/[slug]/page.tsx +21 -4
- package/dist/app/blog/authors/[slug]/page.test.ts +108 -0
- package/dist/app/blog/authors/[slug]/page.tsx +387 -0
- package/dist/app/blog/page.tsx +138 -113
- package/dist/components/AuthorPages.test.ts +87 -0
- package/dist/components/AuthorPages.tsx +129 -0
- package/dist/index.d.mts +142 -70
- package/dist/index.d.ts +142 -70
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -9
- package/dist/index.mjs.map +1 -1
- package/dist/lib/authors.ts +100 -0
- package/dist/lib/sitemap.ts +101 -82
- package/dist/lib/structured-data.ts +3 -2
- package/dist/lib/urls.ts +7 -0
- package/dist/types/contracts.ts +3 -0
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict';var K=require('next/link'),De=require('next/image'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),lucideReact=require('lucide-react'),reactSlot=require('@radix-ui/react-slot'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime'),dateFns=require('date-fns'),rsc=require('next-mdx-remote-client/rsc'),fa6=require('react-icons/fa6'),be=require('react'),je=require('@radix-ui/react-separator'),Ir=require('remark-gfm'),kr=require('remark-toc'),Or=require('rehype-slug'),ratelimit=require('@upstash/ratelimit'),redis=require('@upstash/redis'),drizzleOrm=require('drizzle-orm'),sqliteCore=require('drizzle-orm/sqlite-core'),server=require('next/server');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var K__default=/*#__PURE__*/_interopDefault(K);var De__default=/*#__PURE__*/_interopDefault(De);var be__namespace=/*#__PURE__*/_interopNamespace(be);var je__namespace=/*#__PURE__*/_interopNamespace(je);var Ir__default=/*#__PURE__*/_interopDefault(Ir);var kr__default=/*#__PURE__*/_interopDefault(kr);var Or__default=/*#__PURE__*/_interopDefault(Or);function f(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var pe=classVarianceAuthority.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function Ft({className:e,variant:t,size:r,asChild:n=false,...i}){return jsxRuntime.jsx(n?reactSlot.Slot:"button",{"data-slot":"button",className:f(pe({variant:t,size:r,className:e})),...i})}function Te({className:e,...t}){return jsxRuntime.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:f("mx-auto flex w-full justify-center",e),...t})}function Ce({className:e,...t}){return jsxRuntime.jsx("ul",{"data-slot":"pagination-content",className:f("flex flex-row items-center gap-1",e),...t})}function M({...e}){return jsxRuntime.jsx("li",{"data-slot":"pagination-item",...e})}function z({className:e,isActive:t,size:r="icon",...n}){return jsxRuntime.jsx("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:f(pe({variant:t?"outline":"ghost",size:r}),e),...n})}function Le({className:e,...t}){return jsxRuntime.jsxs(z,{"aria-label":"Go to previous page",size:"default",className:f("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[jsxRuntime.jsx(lucideReact.ChevronLeftIcon,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function Ie({className:e,...t}){return jsxRuntime.jsxs(z,{"aria-label":"Go to next page",size:"default",className:f("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Next"}),jsxRuntime.jsx(lucideReact.ChevronRightIcon,{})]})}function ge({className:e,...t}){return jsxRuntime.jsxs("span",{"aria-hidden":true,"data-slot":"pagination-ellipsis",className:f("flex size-9 items-center justify-center",e),...t,children:[jsxRuntime.jsx(lucideReact.MoreHorizontalIcon,{className:"size-4"}),jsxRuntime.jsx("span",{className:"sr-only",children:"More pages"})]})}function fe({currentPage:e,totalPages:t,baseUrl:r,className:n,maxVisiblePages:i=5,showPrevNext:o=true,showFirstLast:s=true}){if(t<=1)return null;let a=()=>{let d=Math.floor(i/2),g=Math.max(1,e-d),P=Math.min(t,g+i-1);return P-g+1<i&&(g=Math.max(1,P-i+1)),{start:g,end:P}},{start:u,end:l}=a(),m=Array.from({length:l-u+1},(d,g)=>u+g),p=d=>d===1?r:`${r}?page=${d}`,v=e>1,h=e<t;return jsxRuntime.jsxs(Te,{className:n,children:[jsxRuntime.jsxs(Ce,{children:[s&&e>2&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(M,{children:jsxRuntime.jsx(z,{href:p(1),"aria-label":"Go to first page",children:jsxRuntime.jsx(lucideReact.ChevronsLeft,{className:"h-4 w-4"})})}),u>2&&jsxRuntime.jsx(M,{children:jsxRuntime.jsx(ge,{})})]}),o&&jsxRuntime.jsx(M,{children:v?jsxRuntime.jsx(Le,{href:p(e-1)}):jsxRuntime.jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pl-2.5",children:jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Previous"})})}),m.map(d=>jsxRuntime.jsx(M,{children:jsxRuntime.jsx(z,{href:p(d),isActive:d===e,children:d})},d)),o&&jsxRuntime.jsx(M,{children:h?jsxRuntime.jsx(Ie,{href:p(e+1)}):jsxRuntime.jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pr-2.5",children:jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Next"})})}),s&&e<t-1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[l<t-1&&jsxRuntime.jsx(M,{children:jsxRuntime.jsx(ge,{})}),jsxRuntime.jsx(M,{children:jsxRuntime.jsx(z,{href:p(t),"aria-label":"Go to last page",children:jsxRuntime.jsx(lucideReact.ChevronsRight,{className:"h-4 w-4"})})})]})]}),jsxRuntime.jsxs("div",{className:"sr-only","aria-live":"polite",children:["Page ",e," of ",t]})]})}function Qt(e,t=10){let r=e.page,n=Array.isArray(r)?r[0]:r,i=Math.max(1,parseInt(n??"1",10)),o=(i-1)*t;return {currentPage:i,itemsPerPage:t,offset:o,calculateTotalPages:a=>Math.ceil(a/t)}}function Zt(e,t,r,n){let i=n?`${n}${e===1?r:`${r}?page=${e}`}`:void 0,o=e>1&&n?`${n}${e===2?r:`${r}?page=${e-1}`}`:void 0,s=e<t&&n?`${n}${r}?page=${e+1}`:void 0;return {alternates:{...i&&{canonical:i}},other:{...o&&{prev:o},...s&&{next:s}}}}function he(e,t={}){let{customDomain:r,pathPrefix:n="/blog",language:i,isAccessibleForFree:o=true,includeOptionalProperties:s=true}=t,a=r??e.site.domain,u=r?`https://${a}${n}/${e.slug}`:e.meta.canonicalUrl??`https://${a}${n}/${e.slug}`,l=e.author?nt(e.author,{customDomain:r,pathPrefix:n}):void 0,m=Oe(e.site,{customDomain:r,pathPrefix:n}),v=`PT${Math.max(1,Math.ceil(e.readingSeconds/60))}M`,h={"@context":"https://schema.org","@type":"BlogPosting","@id":`${u}#article`,headline:e.title,description:e.excerpt,datePublished:e.publishedAt,dateModified:e.updatedAt,author:l,publisher:m,mainEntityOfPage:{"@type":"WebPage","@id":u},wordCount:e.wordCount,timeRequired:v,isAccessibleForFree:o};return s&&(e.featuredImage&&(h.image=e.featuredImage),e.meta.keywords.length>0&&(h.keywords=[...e.meta.keywords]),(i??e.site.locale)&&(h.inLanguage=i??e.site.locale),e.site.toneAdjectives.length>0&&(h.about=e.site.toneAdjectives.map(d=>({"@type":"Thing",name:d}))),e.site.toneAdjectives.length>0&&(h.genre=[...e.site.toneAdjectives])),h}function nt(e,t={}){let{customDomain:r,pathPrefix:n="/blog"}=t,i={"@context":"https://schema.org","@type":"Person","@id":`#author-${e.id}`,name:e.name,identifier:e.id};e.bio&&(i.description=e.bio),e.avatarUrl&&(i.image=e.avatarUrl);let o=[e.socialLinks?.website,e.socialLinks?.x,e.socialLinks?.linkedin,e.socialLinks?.github].filter(s=>!!s);if(o.length>0&&(i.sameAs=o),e.slug?.trim()){let s=r?`https://${r}${n}/authors/${e.slug}`:`${n}/authors/${e.slug}`;i.url=s;}return e.isGuest&&(i.additionalType="GuestAuthor"),e.toneAdjectives&&e.toneAdjectives.length>0&&(i.knowsAbout=[...e.toneAdjectives]),i}function Oe(e,t={}){let{customDomain:r,pathPrefix:n="/blog"}=t,o=`https://${r??e.domain}${n}`,s={"@context":"https://schema.org","@type":"Organization","@id":`${o}#organization`,name:e.name,url:o};return e.description?.trim()&&(s.description=e.description),e.tagline?.trim()&&(s.description=s.description?`${s.description}. ${e.tagline}`:e.tagline),s}function Be(e,t={}){let{customDomain:r,pathPrefix:n="/blog",language:i,includeSearchAction:o=true}=t,a=`https://${r??e.domain}${n}`,u=Oe(e,t),l={"@context":"https://schema.org","@type":"WebSite","@id":`${a}#website`,name:e.name,url:a,publisher:u};return e.description?.trim()&&(l.description=e.description),(i??e.locale)&&(l.inLanguage=i??e.locale),o&&(l.potentialAction={"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:`${a}?search={search_term_string}`},"query-input":"required name=search_term_string"}),l}function ot(e,t={}){let{customDomain:r}=t;return {"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:e.map((n,i)=>({"@type":"ListItem",position:i+1,name:n.name,item:r&&!n.url.startsWith("http")?`https://${r}${n.url}`:n.url}))}}function _e(e,t={}){let r=[];r.push(he(e,t)),r.push(Be(e.site,t));let n=t.pathPrefix??"/blog",i=[{name:"Home",url:"/"},{name:e.site.name,url:n},{name:e.title,url:`${n}/${e.slug}`}];return r.push(ot(i,t)),r}function Ee(e,t=[],r={}){let n=[];if(n.push(Be(e,r)),t.length>0){let i=t.slice(0,5).map(o=>he(o,r));n.push(...i);}return n}function it(e){let t=[];if(e["@context"]?e["@context"]!=="https://schema.org"&&t.push("@context must be 'https://schema.org'"):t.push("Missing required @context property"),e["@type"]||t.push("Missing required @type property"),e["@type"]==="BlogPosting"){let r=e;r.headline||t.push("BlogPosting: Missing required headline"),r.datePublished||t.push("BlogPosting: Missing required datePublished"),r.author||t.push("BlogPosting: Missing required author"),r.publisher||t.push("BlogPosting: Missing required publisher");}return e["@type"]==="Person"&&(e.name||t.push("Person: Missing required name")),e["@type"]==="Organization"&&(e.name||t.push("Organization: Missing required name")),{isValid:t.length===0,errors:t}}function st(e){return JSON.stringify(e,null,0)}function ne(e){return {type:"application/ld+json",dangerouslySetInnerHTML:{__html:st(e)}}}function er(e){let t=new Set;return e.meta.keywords.forEach(r=>t.add(r)),e.site.toneAdjectives.forEach(r=>t.add(r)),e.author&&e.author.toneAdjectives.forEach(r=>t.add(r)),Array.from(t)}var re=class extends Error{constructor(r,n,i){super(r);this.code=n;this.details=i;this.name="StructuredDataError";}code;details};function tr(e,t={}){try{let r=he(e,t),n=it(r);return n.isValid?{schema:r}:{error:new re("Generated schema validation failed","VALIDATION_FAILED",n.errors)}}catch(r){return {error:new re("Failed to generate structured data","GENERATION_FAILED",r)}}}function k(e="/blog"){let t=e.trim();return !t||t==="/"?"":t.replace(/^(?!\/)/,"/").replace(/\/+$/,"")}function L(e,t){let r=k(e),n=t?.replace(/^\/+/,"").replace(/\/+$/,"");return n?`${r}/${n}`.replace(/\/+/g,"/"):r||"/"}function rr(e){let t=new URL(e);return k(t.pathname)}var X={accentColor:"hsl(var(--primary))",accentHoverColor:"hsl(var(--primary))",textAccentColor:"hsl(var(--primary))",textAccentHoverColor:"hsl(var(--primary))",accentBackgroundColor:"hsl(var(--primary) / 0.08)",accentBorderColor:"hsl(var(--primary) / 0.25)"};function U(e={}){return {"--blog-accent":e.accentColor??X.accentColor,"--blog-accent-hover":e.accentHoverColor??X.accentHoverColor,"--blog-text-accent":e.textAccentColor??e.accentColor??X.textAccentColor,"--blog-text-accent-hover":e.textAccentHoverColor??e.accentHoverColor??X.textAccentHoverColor,"--blog-accent-bg":e.accentBackgroundColor??X.accentBackgroundColor,"--blog-accent-border":e.accentBorderColor??X.accentBorderColor}}function Me(e,t){let r=new Date(e),n=new Date(t);return {publishedDateLabel:dateFns.format(r,"d MMMM yyyy"),publishedRelativeLabel:dateFns.formatDistanceToNow(r,{addSuffix:true}),updatedDateLabel:dateFns.format(n,"d MMMM yyyy"),isUpdated:n.getTime()!==r.getTime()}}function $e(e){let t=[],r=false;for(let n of e.split(`
|
|
2
|
-
`)){if(/^\s*```/.test(n)){r=!r;continue}if(r)continue;let i=/^(#{2,3})\s+(.+?)\s*#*\s*$/.exec(n);if(!i?.[1]||!i[2])continue;let o=or(i[2]);o&&t.push({id:ir(o),text:o,level:i[1].length});}return t}function lt(e){return `${e} ${e===1?"section":"sections"}`}function ct(e,t){let r=e===t;return {isActive:r,ariaCurrent:r?"location":void 0}}function or(e){return e.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_`~]/g,"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim()}function ir(e){return e.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-")}function mt({articles:e,siteName:t,siteTagline:r,className:n,site:i,includeStructuredData:o=false,basePath:s="/blog",pagination:a,theme:u}){let l=k(s)||"/";return jsxRuntime.jsxs("div",{style:U(u),className:f("blog-home-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",n),children:[t&&jsxRuntime.jsxs("header",{className:"blog-header mb-8 text-center sm:mb-12 lg:mb-16",children:[jsxRuntime.jsx("h1",{className:"blog-title mb-2 bg-linear-to-r from-[var(--blog-accent-hover)] to-[var(--blog-accent)] bg-clip-text text-3xl font-semibold tracking-tight text-balance text-transparent sm:text-4xl lg:text-5xl",children:t}),r&&jsxRuntime.jsx("p",{className:"blog-tagline text-muted-foreground text-base sm:text-lg",children:r})]}),jsxRuntime.jsxs("main",{className:"articles-list",children:[e.length===0?jsxRuntime.jsxs("div",{className:"no-articles text-muted-foreground py-16 text-center sm:py-24 lg:py-32",children:[jsxRuntime.jsx("h2",{className:"mb-3 text-xl font-light sm:mb-4 sm:text-2xl lg:text-3xl",children:"No articles yet"}),jsxRuntime.jsx("p",{className:"text-muted-foreground/70 mx-auto max-w-md text-base sm:text-lg",children:"This blog doesn't have any published articles yet."})]}):jsxRuntime.jsx("div",{className:"space-y-0",children:e.map(m=>jsxRuntime.jsx(cr,{article:m,basePath:l},m.id))}),a&&a.totalPages>1&&jsxRuntime.jsx("div",{className:"pagination-wrapper mt-12",children:jsxRuntime.jsx(fe,{currentPage:a.currentPage,totalPages:a.totalPages,baseUrl:a.baseUrl??l,className:"justify-center"})})]}),o&&i&&(()=>{let m=ne(Ee(i,e.slice(0,5),{pathPrefix:l}));return jsxRuntime.jsx("script",{type:m.type,dangerouslySetInnerHTML:m.dangerouslySetInnerHTML})})()]})}function lr(e){return `${Math.ceil(e/60)} min read`}function cr({article:e,basePath:t}){let r=L(t,e.slug),n=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true}),i=lr(e.readingSeconds),o=e.featuredImage;return jsxRuntime.jsx("article",{className:"group border-border mb-6 block border-b pb-6 last:mb-0 last:border-b-0 last:pb-0 sm:mb-8 sm:pb-8",children:jsxRuntime.jsxs(K__default.default,{href:r,className:"focus-visible:ring-ring block rounded-2xl hover:no-underline focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none","aria-label":`Read article: ${e.title}`,children:[jsxRuntime.jsxs("div",{className:"space-y-4 lg:hidden",children:[o&&jsxRuntime.jsx("div",{className:"relative aspect-[16/10] w-full overflow-hidden rounded-2xl",children:jsxRuntime.jsx(De__default.default,{src:o,alt:e.featuredImageAlt??`Featured image for ${e.title}`,width:400,height:250,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-lg leading-tight font-bold text-balance transition-colors sm:text-xl md:text-2xl",children:e.title}),jsxRuntime.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-2 font-medium",children:[jsxRuntime.jsx(ut,{author:e.author,size:"sm"}),e.author.name]}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"})]}),jsxRuntime.jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${n}`,children:n}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:i})]}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed sm:text-base",children:e.excerpt}),(e.topics??[]).length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(s=>jsxRuntime.jsx("span",{className:"rounded-full border border-[var(--blog-accent-border)] px-2.5 py-1 text-xs font-medium text-[var(--blog-text-accent)]",children:s.name},s.id))})]})]}),jsxRuntime.jsxs("div",{className:"hidden items-start gap-6 lg:flex xl:gap-8",children:[o&&jsxRuntime.jsx("div",{className:"relative aspect-[16/10] w-64 shrink-0 overflow-hidden rounded-2xl xl:w-72",children:jsxRuntime.jsx(De__default.default,{src:o,alt:e.featuredImageAlt??`Featured image for ${e.title}`,width:288,height:180,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})}),jsxRuntime.jsxs("div",{className:"flex min-h-[180px] flex-1 flex-col justify-between space-y-4 xl:min-h-[200px]",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-2xl leading-tight font-bold text-balance transition-colors xl:text-3xl",children:e.title}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-base leading-relaxed xl:text-lg",children:e.excerpt}),(e.topics??[]).length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(s=>jsxRuntime.jsx("span",{className:"rounded-full border border-[var(--blog-accent-border)] px-2.5 py-1 text-xs font-medium text-[var(--blog-text-accent)]",children:s.name},s.id))})]}),jsxRuntime.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("span",{className:"inline-flex items-center gap-2 font-medium",children:[jsxRuntime.jsx(ut,{author:e.author,size:"sm"}),e.author.name]}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"})]}),jsxRuntime.jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${n}`,children:n}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:i})]})]})]})]})})}function ut({author:e,size:t}){let r=t==="md"?"h-9 w-9 text-sm":"h-6 w-6 text-xs",n=ur(e.name);return e.avatarUrl?jsxRuntime.jsx(De__default.default,{src:e.avatarUrl,alt:e.name,width:t==="md"?36:24,height:t==="md"?36:24,className:f("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsxRuntime.jsx("span",{className:f("bg-muted inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function ur(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function dr(e,t,r,n,i="/blog"){let o=e?`${e} - Blog`:"Blog",s=n&&n.currentPage>1?`${o} - Page ${n.currentPage}`:o,a=t??"Read our latest articles and insights.",u=k(i)||"/",l=r?`${r}${n&&n.currentPage>1?`${u}?page=${n.currentPage}`:u}`:void 0,m=n&&n.currentPage>1&&r?`${r}${n.currentPage===2?u:`${u}?page=${n.currentPage-1}`}`:void 0,p=n&&n.currentPage<n.totalPages&&r?`${r}${u}?page=${n.currentPage+1}`:void 0;return {title:s,description:a,openGraph:{title:s,description:a,type:"website",...r&&{url:l}},twitter:{card:"summary_large_image",title:s,description:a},alternates:{...l&&{canonical:l}},other:{...m&&{prev:m},...p&&{next:p}}}}var pr=classVarianceAuthority.cva("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ue({className:e,variant:t,...r}){return jsxRuntime.jsx("div",{className:f(pr({variant:t}),e),...r})}function oe({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card",className:f("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function fr({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-header",className:f("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function hr({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-title",className:f("leading-none font-semibold",e),...t})}function br({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-description",className:f("text-muted-foreground text-sm",e),...t})}function ie({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-content",className:f("px-6",e),...t})}function xr({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-footer",className:f("flex items-center px-6 [.border-t]:pt-6",e),...t})}function Ar(e,t){try{return new URL(e).href}catch{if(!t)return e}try{return new URL(e,t).href}catch{return e}}async function pt(e,t=globalThis.navigator?.clipboard,r=typeof document>"u"?void 0:document){if(t)try{await t.writeText(e);return}catch{}if(!r)throw new Error("Clipboard API is unavailable");let n=r.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.left="-9999px",r.body.appendChild(n),n.select();try{if(!r.execCommand("copy"))throw new Error("Copy command failed")}finally{n.remove();}}async function wr(e,t=globalThis.navigator){return t?.share?(await t.share({title:e.title,url:e.url}),"shared"):(await pt(e.url,t?.clipboard),"copied")}function xe({title:e,url:t,className:r,size:n="md"}){let[i,o]=be__namespace.default.useState(false),[s,a]=be__namespace.default.useState(false),u=be__namespace.default.useMemo(()=>Ar(t,typeof window>"u"?void 0:window.location.href),[t]);be__namespace.default.useEffect(()=>{if(!i)return;let h=window.setTimeout(()=>o(false),2e3);return ()=>window.clearTimeout(h)},[i]);async function l(){await pt(u),o(true);}async function m(){a(true);try{await wr({title:e,url:u})==="copied"&&o(!0);}finally{a(false);}}let p=n==="sm"?"h-8 gap-1.5 px-2.5 text-xs":"h-9 gap-2 px-3 text-sm",v=n==="sm"?"size-3.5":"size-4";return jsxRuntime.jsxs("div",{className:f("article-top-actions flex flex-wrap items-center justify-center gap-2",r),children:[jsxRuntime.jsxs("button",{type:"button","aria-label":"Copy article link",onClick:l,className:f("text-muted-foreground hover:text-foreground border-border inline-flex items-center justify-center rounded-full border font-medium transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",p),children:[i?jsxRuntime.jsx(lucideReact.Check,{className:v,"aria-hidden":"true"}):jsxRuntime.jsx(lucideReact.Copy,{className:v,"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:i?"Copied":"Copy link"})]}),jsxRuntime.jsxs("button",{type:"button","aria-label":"Share article",onClick:m,disabled:s,className:f("text-muted-foreground hover:text-foreground border-border inline-flex items-center justify-center rounded-full border font-medium transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)] disabled:cursor-wait disabled:opacity-60",p),children:[jsxRuntime.jsx(lucideReact.Share2,{className:v,"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:"Share"})]})]})}function ft({alt:e="",className:t,src:r,...n}){if(typeof r!="string"||r.length===0)return jsxRuntime.jsx("img",{alt:e,className:t,...n});let i=`blog-image-preview-${Sr(r)}`;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("a",{href:`#${i}`,className:"group mx-auto block cursor-zoom-in rounded-2xl focus-visible:ring-2 focus-visible:ring-[var(--blog-text-accent)] focus-visible:ring-offset-2 focus-visible:outline-none","aria-label":e?`Expand image: ${e}`:"Expand article image",children:jsxRuntime.jsx("img",{src:r,alt:e,className:f("mx-auto rounded-2xl border border-[var(--blog-accent-border)] shadow-[0_18px_60px_rgb(168_85_247_/_0.12)] transition-opacity group-hover:opacity-95",t),...n})}),jsxRuntime.jsxs("div",{id:i,className:"invisible fixed inset-0 z-50 flex opacity-0 transition-opacity target:visible target:opacity-100",role:"dialog","aria-modal":"true","aria-label":e?`Image preview: ${e}`:"Image preview",children:[jsxRuntime.jsx("a",{href:"#article-content",className:"absolute inset-0 bg-black/85 backdrop-blur-sm","aria-label":"Close image preview"}),jsxRuntime.jsx("div",{className:"pointer-events-none relative z-10 flex min-h-screen w-full items-center justify-center p-4 sm:p-6",children:jsxRuntime.jsx("img",{src:r,alt:e,className:"pointer-events-auto h-[88vh] w-[94vw] rounded-3xl object-contain shadow-2xl"})}),jsxRuntime.jsx("a",{href:"#article-content",className:"absolute top-4 right-4 z-20 inline-flex size-10 items-center justify-center rounded-full border border-white/20 bg-black/50 text-xl leading-none text-white no-underline transition-colors hover:bg-white/10 focus-visible:ring-2 focus-visible:ring-white focus-visible:outline-none","aria-label":"Close image preview",children:"\xD7"})]})]})}function Sr(e){let t=0;for(let r=0;r<e.length;r+=1)t=(t<<5)-t+e.charCodeAt(r),t|=0;return Math.abs(t).toString(36)}function Ve({items:e,contentId:t,variant:r,showProgress:n=true}){let i=e[0]?.id??null;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n&&jsxRuntime.jsx("div",{"data-blog-reading-progress":t,className:"fixed inset-x-0 top-0 z-50 h-1 origin-left bg-[var(--blog-accent)] motion-safe:transition-transform",style:{transform:"scaleX(0)"},role:"progressbar","aria-label":"Reading progress","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":0,suppressHydrationWarning:true}),jsxRuntime.jsx(Nr,{items:e,activeItemId:i,variant:r}),n&&jsxRuntime.jsx("script",{dangerouslySetInnerHTML:{__html:Tr(t,e)}})]})}function Nr({items:e,activeItemId:t,variant:r}){if(e.length===0)return null;let n=jsxRuntime.jsx("ul",{className:"space-y-2 text-sm",children:e.map(i=>{let o=ct(i.id,t);return jsxRuntime.jsx("li",{className:i.level===3?"pl-4":void 0,children:jsxRuntime.jsx("a",{href:`#${i.id}`,"aria-current":o.ariaCurrent,"data-blog-toc-link":i.id,"data-active":o.isActive?"true":"false",suppressHydrationWarning:true,className:"text-muted-foreground hover:text-[var(--blog-text-accent)] data-[active=true]:border-[var(--blog-accent)] data-[active=true]:text-[var(--blog-text-accent)] block border-l-2 border-transparent pl-3 leading-snug transition-colors",children:i.text})},i.id)})});return r==="mobile"?jsxRuntime.jsxs("details",{className:"group mb-6 rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] lg:hidden",children:[jsxRuntime.jsxs("summary",{className:"text-foreground flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold [&::-webkit-details-marker]:hidden",children:[jsxRuntime.jsx("span",{children:"On this page"}),jsxRuntime.jsxs("span",{className:"text-muted-foreground flex items-center gap-2 text-xs font-medium",children:[lt(e.length),jsxRuntime.jsx("span",{className:"text-[var(--blog-text-accent)] transition-transform group-open:rotate-180","aria-hidden":"true",children:"\u2193"})]})]}),jsxRuntime.jsx("nav",{"aria-label":"Table of contents",className:"border-t border-[var(--blog-accent-border)] px-4 py-4",children:n})]}):jsxRuntime.jsx("aside",{className:"hidden lg:block",children:jsxRuntime.jsxs("nav",{"aria-label":"Table of contents",className:"sticky top-24 max-h-[calc(100vh-8rem)] overflow-y-auto border-l border-border pl-5",children:[jsxRuntime.jsx("p",{className:"text-muted-foreground mb-3 text-xs font-semibold tracking-wider uppercase",children:"On this page"}),n]})})}function Tr(e,t){return `
|
|
1
|
+
'use strict';var F=require('next/link'),qe=require('next/image'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),lucideReact=require('lucide-react'),reactSlot=require('@radix-ui/react-slot'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime'),dateFns=require('date-fns'),rsc=require('next-mdx-remote-client/rsc'),fa6=require('react-icons/fa6'),Ne=require('react'),Ke=require('@radix-ui/react-separator'),Gr=require('remark-gfm'),Vr=require('remark-toc'),Fr=require('rehype-slug'),ratelimit=require('@upstash/ratelimit'),redis=require('@upstash/redis'),drizzleOrm=require('drizzle-orm'),sqliteCore=require('drizzle-orm/sqlite-core'),server=require('next/server');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var F__default=/*#__PURE__*/_interopDefault(F);var qe__default=/*#__PURE__*/_interopDefault(qe);var Ne__namespace=/*#__PURE__*/_interopNamespace(Ne);var Ke__namespace=/*#__PURE__*/_interopNamespace(Ke);var Gr__default=/*#__PURE__*/_interopDefault(Gr);var Vr__default=/*#__PURE__*/_interopDefault(Vr);var Fr__default=/*#__PURE__*/_interopDefault(Fr);function f(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var Pe=classVarianceAuthority.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function or({className:e,variant:t,size:r,asChild:n=false,...i}){return jsxRuntime.jsx(n?reactSlot.Slot:"button",{"data-slot":"button",className:f(Pe({variant:t,size:r,className:e})),...i})}function Ee({className:e,...t}){return jsxRuntime.jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:f("mx-auto flex w-full justify-center",e),...t})}function Me({className:e,...t}){return jsxRuntime.jsx("ul",{"data-slot":"pagination-content",className:f("flex flex-row items-center gap-1",e),...t})}function z({...e}){return jsxRuntime.jsx("li",{"data-slot":"pagination-item",...e})}function K({className:e,isActive:t,size:r="icon",...n}){return jsxRuntime.jsx("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:f(Pe({variant:t?"outline":"ghost",size:r}),e),...n})}function $e({className:e,...t}){return jsxRuntime.jsxs(K,{"aria-label":"Go to previous page",size:"default",className:f("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[jsxRuntime.jsx(lucideReact.ChevronLeftIcon,{}),jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function De({className:e,...t}){return jsxRuntime.jsxs(K,{"aria-label":"Go to next page",size:"default",className:f("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Next"}),jsxRuntime.jsx(lucideReact.ChevronRightIcon,{})]})}function Ae({className:e,...t}){return jsxRuntime.jsxs("span",{"aria-hidden":true,"data-slot":"pagination-ellipsis",className:f("flex size-9 items-center justify-center",e),...t,children:[jsxRuntime.jsx(lucideReact.MoreHorizontalIcon,{className:"size-4"}),jsxRuntime.jsx("span",{className:"sr-only",children:"More pages"})]})}function ee({currentPage:e,totalPages:t,baseUrl:r,className:n,maxVisiblePages:i=5,showPrevNext:o=true,showFirstLast:a=true}){if(t<=1)return null;let s=()=>{let p=Math.floor(i/2),g=Math.max(1,e-p),A=Math.min(t,g+i-1);return A-g+1<i&&(g=Math.max(1,A-i+1)),{start:g,end:A}},{start:l,end:c}=s(),d=Array.from({length:c-l+1},(p,g)=>l+g),m=p=>p===1?r:`${r}?page=${p}`,x=e>1,h=e<t;return jsxRuntime.jsxs(Ee,{className:n,children:[jsxRuntime.jsxs(Me,{children:[a&&e>2&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(z,{children:jsxRuntime.jsx(K,{href:m(1),"aria-label":"Go to first page",children:jsxRuntime.jsx(lucideReact.ChevronsLeft,{className:"h-4 w-4"})})}),l>2&&jsxRuntime.jsx(z,{children:jsxRuntime.jsx(Ae,{})})]}),o&&jsxRuntime.jsx(z,{children:x?jsxRuntime.jsx($e,{href:m(e-1)}):jsxRuntime.jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pl-2.5",children:jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Previous"})})}),d.map(p=>jsxRuntime.jsx(z,{children:jsxRuntime.jsx(K,{href:m(p),isActive:p===e,children:p})},p)),o&&jsxRuntime.jsx(z,{children:h?jsxRuntime.jsx(De,{href:m(e+1)}):jsxRuntime.jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pr-2.5",children:jsxRuntime.jsx("span",{className:"hidden sm:block",children:"Next"})})}),a&&e<t-1&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[c<t-1&&jsxRuntime.jsx(z,{children:jsxRuntime.jsx(Ae,{})}),jsxRuntime.jsx(z,{children:jsxRuntime.jsx(K,{href:m(t),"aria-label":"Go to last page",children:jsxRuntime.jsx(lucideReact.ChevronsRight,{className:"h-4 w-4"})})})]})]}),jsxRuntime.jsxs("div",{className:"sr-only","aria-live":"polite",children:["Page ",e," of ",t]})]})}function dr(e,t=10){let r=e.page,n=Array.isArray(r)?r[0]:r,i=Math.max(1,parseInt(n??"1",10)),o=(i-1)*t;return {currentPage:i,itemsPerPage:t,offset:o,calculateTotalPages:s=>Math.ceil(s/t)}}function mr(e,t,r,n){let i=n?`${n}${e===1?r:`${r}?page=${e}`}`:void 0,o=e>1&&n?`${n}${e===2?r:`${r}?page=${e-1}`}`:void 0,a=e<t&&n?`${n}${r}?page=${e+1}`:void 0;return {alternates:{...i&&{canonical:i}},other:{...o&&{prev:o},...a&&{next:a}}}}function T(e="/blog"){let t=e.trim();return !t||t==="/"?"":t.replace(/^(?!\/)/,"/").replace(/\/+$/,"")}function C(e,t){let r=T(e),n=t?.replace(/^\/+/,"").replace(/\/+$/,"");return n?`${r}/${n}`.replace(/\/+/g,"/"):r||"/"}function R(e,t){return C(e,`authors/${t}`)}function pr(e){let t=new URL(e);return T(t.pathname)}function we(e,t={}){let{customDomain:r,pathPrefix:n="/blog",language:i,isAccessibleForFree:o=true,includeOptionalProperties:a=true}=t,s=r??e.site.domain,l=r?`https://${s}${n}/${e.slug}`:e.meta.canonicalUrl??`https://${s}${n}/${e.slug}`,c=e.author?Se(e.author,{customDomain:r,pathPrefix:n}):void 0,d=He(e.site,{customDomain:r,pathPrefix:n}),x=`PT${Math.max(1,Math.ceil(e.readingSeconds/60))}M`,h={"@context":"https://schema.org","@type":"BlogPosting","@id":`${l}#article`,headline:e.title,description:e.excerpt,datePublished:e.publishedAt,dateModified:e.updatedAt,author:c,publisher:d,mainEntityOfPage:{"@type":"WebPage","@id":l},wordCount:e.wordCount,timeRequired:x,isAccessibleForFree:o};return a&&(e.featuredImage&&(h.image=e.featuredImage),e.meta.keywords.length>0&&(h.keywords=[...e.meta.keywords]),(i??e.site.locale)&&(h.inLanguage=i??e.site.locale),e.site.toneAdjectives.length>0&&(h.about=e.site.toneAdjectives.map(p=>({"@type":"Thing",name:p}))),e.site.toneAdjectives.length>0&&(h.genre=[...e.site.toneAdjectives])),h}function Se(e,t={}){let{customDomain:r,pathPrefix:n="/blog"}=t,i={"@context":"https://schema.org","@type":"Person","@id":`#author-${e.id}`,name:e.name,identifier:e.id};e.bio&&(i.description=e.bio),e.avatarUrl&&(i.image=e.avatarUrl);let o=[e.socialLinks?.website,e.socialLinks?.x,e.socialLinks?.linkedin,e.socialLinks?.github].filter(a=>!!a);if(o.length>0&&(i.sameAs=o),e.slug?.trim()){let a=r?`https://${r}${R(n,e.slug)}`:R(n,e.slug);i.url=a;}return e.isGuest&&(i.additionalType="GuestAuthor"),e.toneAdjectives&&e.toneAdjectives.length>0&&(i.knowsAbout=[...e.toneAdjectives]),i}function He(e,t={}){let{customDomain:r,pathPrefix:n="/blog"}=t,o=`https://${r??e.domain}${n}`,a={"@context":"https://schema.org","@type":"Organization","@id":`${o}#organization`,name:e.name,url:o};return e.description?.trim()&&(a.description=e.description),e.tagline?.trim()&&(a.description=a.description?`${a.description}. ${e.tagline}`:e.tagline),a}function je(e,t={}){let{customDomain:r,pathPrefix:n="/blog",language:i,includeSearchAction:o=true}=t,s=`https://${r??e.domain}${n}`,l=He(e,t),c={"@context":"https://schema.org","@type":"WebSite","@id":`${s}#website`,name:e.name,url:s,publisher:l};return e.description?.trim()&&(c.description=e.description),(i??e.locale)&&(c.inLanguage=i??e.locale),o&&(c.potentialAction={"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:`${s}?search={search_term_string}`},"query-input":"required name=search_term_string"}),c}function dt(e,t={}){let{customDomain:r}=t;return {"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:e.map((n,i)=>({"@type":"ListItem",position:i+1,name:n.name,item:r&&!n.url.startsWith("http")?`https://${r}${n.url}`:n.url}))}}function ze(e,t={}){let r=[];r.push(we(e,t)),r.push(je(e.site,t));let n=t.pathPrefix??"/blog",i=[{name:"Home",url:"/"},{name:e.site.name,url:n},{name:e.title,url:`${n}/${e.slug}`}];return r.push(dt(i,t)),r}function Ge(e,t=[],r={}){let n=[];if(n.push(je(e,r)),t.length>0){let i=t.slice(0,5).map(o=>we(o,r));n.push(...i);}return n}function mt(e){let t=[];if(e["@context"]?e["@context"]!=="https://schema.org"&&t.push("@context must be 'https://schema.org'"):t.push("Missing required @context property"),e["@type"]||t.push("Missing required @type property"),e["@type"]==="BlogPosting"){let r=e;r.headline||t.push("BlogPosting: Missing required headline"),r.datePublished||t.push("BlogPosting: Missing required datePublished"),r.author||t.push("BlogPosting: Missing required author"),r.publisher||t.push("BlogPosting: Missing required publisher");}return e["@type"]==="Person"&&(e.name||t.push("Person: Missing required name")),e["@type"]==="Organization"&&(e.name||t.push("Organization: Missing required name")),{isValid:t.length===0,errors:t}}function pt(e){return JSON.stringify(e,null,0)}function J(e){return {type:"application/ld+json",dangerouslySetInnerHTML:{__html:pt(e)}}}function gr(e){let t=new Set;return e.meta.keywords.forEach(r=>t.add(r)),e.site.toneAdjectives.forEach(r=>t.add(r)),e.author&&e.author.toneAdjectives.forEach(r=>t.add(r)),Array.from(t)}var ce=class extends Error{constructor(r,n,i){super(r);this.code=n;this.details=i;this.name="StructuredDataError";}code;details};function fr(e,t={}){try{let r=we(e,t),n=mt(r);return n.isValid?{schema:r}:{error:new ce("Generated schema validation failed","VALIDATION_FAILED",n.errors)}}catch(r){return {error:new ce("Failed to generate structured data","GENERATION_FAILED",r)}}}var te={accentColor:"hsl(var(--primary))",accentHoverColor:"hsl(var(--primary))",textAccentColor:"hsl(var(--primary))",textAccentHoverColor:"hsl(var(--primary))",accentBackgroundColor:"hsl(var(--primary) / 0.08)",accentBorderColor:"hsl(var(--primary) / 0.25)"};function _(e={}){return {"--blog-accent":e.accentColor??te.accentColor,"--blog-accent-hover":e.accentHoverColor??te.accentHoverColor,"--blog-text-accent":e.textAccentColor??e.accentColor??te.textAccentColor,"--blog-text-accent-hover":e.textAccentHoverColor??e.accentHoverColor??te.textAccentHoverColor,"--blog-accent-bg":e.accentBackgroundColor??te.accentBackgroundColor,"--blog-accent-border":e.accentBorderColor??te.accentBorderColor}}function Ve(e,t){let r=new Date(e),n=new Date(t);return {publishedDateLabel:dateFns.format(r,"d MMMM yyyy"),publishedRelativeLabel:dateFns.formatDistanceToNow(r,{addSuffix:true}),updatedDateLabel:dateFns.format(n,"d MMMM yyyy"),isUpdated:n.getTime()!==r.getTime()}}function Fe(e){let t=[],r=false;for(let n of e.split(`
|
|
2
|
+
`)){if(/^\s*```/.test(n)){r=!r;continue}if(r)continue;let i=/^(#{2,3})\s+(.+?)\s*#*\s*$/.exec(n);if(!i?.[1]||!i[2])continue;let o=br(i[2]);o&&t.push({id:xr(o),text:o,level:i[1].length});}return t}function ft(e){return `${e} ${e===1?"section":"sections"}`}function ht(e,t){let r=e===t;return {isActive:r,ariaCurrent:r?"location":void 0}}function br(e){return e.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_`~]/g,"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim()}function xr(e){return e.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-")}function yt({articles:e,siteName:t,siteTagline:r,className:n,site:i,includeStructuredData:o=false,basePath:a="/blog",pagination:s,theme:l}){let c=T(a)||"/";return jsxRuntime.jsxs("div",{style:_(l),className:f("blog-home-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",n),children:[t&&jsxRuntime.jsxs("header",{className:"blog-header mb-8 text-center sm:mb-12 lg:mb-16",children:[jsxRuntime.jsx("h1",{className:"blog-title mb-2 bg-linear-to-r from-[var(--blog-accent-hover)] to-[var(--blog-accent)] bg-clip-text text-3xl font-semibold tracking-tight text-balance text-transparent sm:text-4xl lg:text-5xl",children:t}),r&&jsxRuntime.jsx("p",{className:"blog-tagline text-muted-foreground text-base sm:text-lg",children:r})]}),jsxRuntime.jsxs("main",{className:"articles-list",children:[e.length===0?jsxRuntime.jsxs("div",{className:"no-articles text-muted-foreground py-16 text-center sm:py-24 lg:py-32",children:[jsxRuntime.jsx("h2",{className:"mb-3 text-xl font-light sm:mb-4 sm:text-2xl lg:text-3xl",children:"No articles yet"}),jsxRuntime.jsx("p",{className:"text-muted-foreground/70 mx-auto max-w-md text-base sm:text-lg",children:"This blog doesn't have any published articles yet."})]}):jsxRuntime.jsx("div",{className:"space-y-0",children:e.map(d=>jsxRuntime.jsx(Pr,{article:d,basePath:c},d.id))}),s&&s.totalPages>1&&jsxRuntime.jsx("div",{className:"pagination-wrapper mt-12",children:jsxRuntime.jsx(ee,{currentPage:s.currentPage,totalPages:s.totalPages,baseUrl:s.baseUrl??c,className:"justify-center"})})]}),o&&i&&(()=>{let d=J(Ge(i,e.slice(0,5),{pathPrefix:c}));return jsxRuntime.jsx("script",{type:d.type,dangerouslySetInnerHTML:d.dangerouslySetInnerHTML})})()]})}function vr(e){return `${Math.ceil(e/60)} min read`}function Pr({article:e,basePath:t}){let r=C(t,e.slug),n=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true}),i=vr(e.readingSeconds),o=e.featuredImage;return jsxRuntime.jsxs("article",{className:"group border-border mb-6 block border-b pb-6 last:mb-0 last:border-b-0 last:pb-0 sm:mb-8 sm:pb-8",children:[jsxRuntime.jsxs("div",{className:"space-y-4 lg:hidden",children:[o&&jsxRuntime.jsx(F__default.default,{href:r,className:"focus-visible:ring-ring relative block aspect-[16/10] w-full overflow-hidden rounded-2xl focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none","aria-label":`Read article: ${e.title}`,children:jsxRuntime.jsx(qe__default.default,{src:o,alt:e.featuredImageAlt??`Featured image for ${e.title}`,width:400,height:250,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})}),jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsx(F__default.default,{href:r,className:"focus-visible:ring-ring block rounded-md hover:no-underline focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",children:jsxRuntime.jsx("h2",{className:"text-lg leading-tight font-bold text-balance transition-colors group-hover:text-[var(--blog-accent)] sm:text-xl md:text-2xl",children:e.title})}),jsxRuntime.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(bt,{author:e.author,basePath:t}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"})]}),jsxRuntime.jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${n}`,children:n}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:i})]}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed sm:text-base",children:e.excerpt}),(e.topics??[]).length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(a=>jsxRuntime.jsx("span",{className:"rounded-full border border-[var(--blog-accent-border)] px-2.5 py-1 text-xs font-medium text-[var(--blog-text-accent)]",children:a.name},a.id))})]})]}),jsxRuntime.jsxs("div",{className:"hidden items-start gap-6 lg:flex xl:gap-8",children:[o&&jsxRuntime.jsx(F__default.default,{href:r,className:"focus-visible:ring-ring relative block aspect-[16/10] w-64 shrink-0 overflow-hidden rounded-2xl focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none xl:w-72","aria-label":`Read article: ${e.title}`,children:jsxRuntime.jsx(qe__default.default,{src:o,alt:e.featuredImageAlt??`Featured image for ${e.title}`,width:288,height:180,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})}),jsxRuntime.jsxs("div",{className:"flex min-h-[180px] flex-1 flex-col justify-between space-y-4 xl:min-h-[200px]",children:[jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsx(F__default.default,{href:r,className:"focus-visible:ring-ring block rounded-md hover:no-underline focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",children:jsxRuntime.jsx("h2",{className:"text-2xl leading-tight font-bold text-balance transition-colors group-hover:text-[var(--blog-accent)] xl:text-3xl",children:e.title})}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-base leading-relaxed xl:text-lg",children:e.excerpt}),(e.topics??[]).length>0&&jsxRuntime.jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(a=>jsxRuntime.jsx("span",{className:"rounded-full border border-[var(--blog-accent-border)] px-2.5 py-1 text-xs font-medium text-[var(--blog-text-accent)]",children:a.name},a.id))})]}),jsxRuntime.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(bt,{author:e.author,basePath:t}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"})]}),jsxRuntime.jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${n}`,children:n}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:i})]})]})]})]})}function bt({author:e,basePath:t}){return jsxRuntime.jsxs(F__default.default,{href:R(t,e.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsxRuntime.jsx(Ar,{author:e,size:"sm"}),e.name]})}function Ar({author:e,size:t}){let r=t==="md"?"h-9 w-9 text-sm":"h-6 w-6 text-xs",n=wr(e.name);return e.avatarUrl?jsxRuntime.jsx(qe__default.default,{src:e.avatarUrl,alt:e.name,width:t==="md"?36:24,height:t==="md"?36:24,className:f("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsxRuntime.jsx("span",{className:f("bg-muted inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function wr(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function Sr(e,t,r,n,i="/blog"){let o=e?`${e} - Blog`:"Blog",a=n&&n.currentPage>1?`${o} - Page ${n.currentPage}`:o,s=t??"Read our latest articles and insights.",l=T(i)||"/",c=r?`${r}${n&&n.currentPage>1?`${l}?page=${n.currentPage}`:l}`:void 0,d=n&&n.currentPage>1&&r?`${r}${n.currentPage===2?l:`${l}?page=${n.currentPage-1}`}`:void 0,m=n&&n.currentPage<n.totalPages&&r?`${r}${l}?page=${n.currentPage+1}`:void 0;return {title:a,description:s,openGraph:{title:a,description:s,type:"website",...r&&{url:c}},twitter:{card:"summary_large_image",title:a,description:s},alternates:{...c&&{canonical:c}},other:{...d&&{prev:d},...m&&{next:m}}}}var Rr=classVarianceAuthority.cva("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function de({className:e,variant:t,...r}){return jsxRuntime.jsx("div",{className:f(Rr({variant:t}),e),...r})}function me({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card",className:f("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function Cr({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-header",className:f("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...t})}function Lr({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-title",className:f("leading-none font-semibold",e),...t})}function kr({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-description",className:f("text-muted-foreground text-sm",e),...t})}function pe({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-content",className:f("px-6",e),...t})}function Ir({className:e,...t}){return jsxRuntime.jsx("div",{"data-slot":"card-footer",className:f("flex items-center px-6 [.border-t]:pt-6",e),...t})}function Er(e,t){try{return new URL(e).href}catch{if(!t)return e}try{return new URL(e,t).href}catch{return e}}async function vt(e,t=globalThis.navigator?.clipboard,r=typeof document>"u"?void 0:document){if(t)try{await t.writeText(e);return}catch{}if(!r)throw new Error("Clipboard API is unavailable");let n=r.createElement("textarea");n.value=e,n.setAttribute("readonly",""),n.style.position="fixed",n.style.left="-9999px",r.body.appendChild(n),n.select();try{if(!r.execCommand("copy"))throw new Error("Copy command failed")}finally{n.remove();}}async function Mr(e,t=globalThis.navigator){return t?.share?(await t.share({title:e.title,url:e.url}),"shared"):(await vt(e.url,t?.clipboard),"copied")}function Re({title:e,url:t,className:r,size:n="md"}){let[i,o]=Ne__namespace.default.useState(false),[a,s]=Ne__namespace.default.useState(false),l=Ne__namespace.default.useMemo(()=>Er(t,typeof window>"u"?void 0:window.location.href),[t]);Ne__namespace.default.useEffect(()=>{if(!i)return;let h=window.setTimeout(()=>o(false),2e3);return ()=>window.clearTimeout(h)},[i]);async function c(){await vt(l),o(true);}async function d(){s(true);try{await Mr({title:e,url:l})==="copied"&&o(!0);}finally{s(false);}}let m=n==="sm"?"h-8 gap-1.5 px-2.5 text-xs":"h-9 gap-2 px-3 text-sm",x=n==="sm"?"size-3.5":"size-4";return jsxRuntime.jsxs("div",{className:f("article-top-actions flex flex-wrap items-center justify-center gap-2",r),children:[jsxRuntime.jsxs("button",{type:"button","aria-label":"Copy article link",onClick:c,className:f("text-muted-foreground hover:text-foreground border-border inline-flex items-center justify-center rounded-full border font-medium transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",m),children:[i?jsxRuntime.jsx(lucideReact.Check,{className:x,"aria-hidden":"true"}):jsxRuntime.jsx(lucideReact.Copy,{className:x,"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:i?"Copied":"Copy link"})]}),jsxRuntime.jsxs("button",{type:"button","aria-label":"Share article",onClick:d,disabled:a,className:f("text-muted-foreground hover:text-foreground border-border inline-flex items-center justify-center rounded-full border font-medium transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)] disabled:cursor-wait disabled:opacity-60",m),children:[jsxRuntime.jsx(lucideReact.Share2,{className:x,"aria-hidden":"true"}),jsxRuntime.jsx("span",{children:"Share"})]})]})}function At({alt:e="",className:t,src:r,...n}){if(typeof r!="string"||r.length===0)return jsxRuntime.jsx("img",{alt:e,className:t,...n});let i=`blog-image-preview-${$r(r)}`;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("a",{href:`#${i}`,className:"group mx-auto block cursor-zoom-in rounded-2xl focus-visible:ring-2 focus-visible:ring-[var(--blog-text-accent)] focus-visible:ring-offset-2 focus-visible:outline-none","aria-label":e?`Expand image: ${e}`:"Expand article image",children:jsxRuntime.jsx("img",{src:r,alt:e,className:f("mx-auto rounded-2xl border border-[var(--blog-accent-border)] shadow-[0_18px_60px_rgb(168_85_247_/_0.12)] transition-opacity group-hover:opacity-95",t),...n})}),jsxRuntime.jsxs("div",{id:i,className:"invisible fixed inset-0 z-50 flex opacity-0 transition-opacity target:visible target:opacity-100",role:"dialog","aria-modal":"true","aria-label":e?`Image preview: ${e}`:"Image preview",children:[jsxRuntime.jsx("a",{href:"#article-content",className:"absolute inset-0 bg-black/85 backdrop-blur-sm","aria-label":"Close image preview"}),jsxRuntime.jsx("div",{className:"pointer-events-none relative z-10 flex min-h-screen w-full items-center justify-center p-4 sm:p-6",children:jsxRuntime.jsx("img",{src:r,alt:e,className:"pointer-events-auto h-[88vh] w-[94vw] rounded-3xl object-contain shadow-2xl"})}),jsxRuntime.jsx("a",{href:"#article-content",className:"absolute top-4 right-4 z-20 inline-flex size-10 items-center justify-center rounded-full border border-white/20 bg-black/50 text-xl leading-none text-white no-underline transition-colors hover:bg-white/10 focus-visible:ring-2 focus-visible:ring-white focus-visible:outline-none","aria-label":"Close image preview",children:"\xD7"})]})]})}function $r(e){let t=0;for(let r=0;r<e.length;r+=1)t=(t<<5)-t+e.charCodeAt(r),t|=0;return Math.abs(t).toString(36)}function We({items:e,contentId:t,variant:r,showProgress:n=true}){let i=e[0]?.id??null;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[n&&jsxRuntime.jsx("div",{"data-blog-reading-progress":t,className:"fixed inset-x-0 top-0 z-50 h-1 origin-left bg-[var(--blog-accent)] motion-safe:transition-transform",style:{transform:"scaleX(0)"},role:"progressbar","aria-label":"Reading progress","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":0,suppressHydrationWarning:true}),jsxRuntime.jsx(Ur,{items:e,activeItemId:i,variant:r}),n&&jsxRuntime.jsx("script",{dangerouslySetInnerHTML:{__html:Hr(t,e)}})]})}function Ur({items:e,activeItemId:t,variant:r}){if(e.length===0)return null;let n=jsxRuntime.jsx("ul",{className:"space-y-2 text-sm",children:e.map(i=>{let o=ht(i.id,t);return jsxRuntime.jsx("li",{className:i.level===3?"pl-4":void 0,children:jsxRuntime.jsx("a",{href:`#${i.id}`,"aria-current":o.ariaCurrent,"data-blog-toc-link":i.id,"data-active":o.isActive?"true":"false",suppressHydrationWarning:true,className:"text-muted-foreground hover:text-[var(--blog-text-accent)] data-[active=true]:border-[var(--blog-accent)] data-[active=true]:text-[var(--blog-text-accent)] block border-l-2 border-transparent pl-3 leading-snug transition-colors",children:i.text})},i.id)})});return r==="mobile"?jsxRuntime.jsxs("details",{className:"group mb-6 rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] lg:hidden",children:[jsxRuntime.jsxs("summary",{className:"text-foreground flex cursor-pointer list-none items-center justify-between gap-3 px-4 py-3 text-sm font-semibold [&::-webkit-details-marker]:hidden",children:[jsxRuntime.jsx("span",{children:"On this page"}),jsxRuntime.jsxs("span",{className:"text-muted-foreground flex items-center gap-2 text-xs font-medium",children:[ft(e.length),jsxRuntime.jsx("span",{className:"text-[var(--blog-text-accent)] transition-transform group-open:rotate-180","aria-hidden":"true",children:"\u2193"})]})]}),jsxRuntime.jsx("nav",{"aria-label":"Table of contents",className:"border-t border-[var(--blog-accent-border)] px-4 py-4",children:n})]}):jsxRuntime.jsx("aside",{className:"hidden lg:block",children:jsxRuntime.jsxs("nav",{"aria-label":"Table of contents",className:"sticky top-24 max-h-[calc(100vh-8rem)] overflow-y-auto border-l border-border pl-5",children:[jsxRuntime.jsx("p",{className:"text-muted-foreground mb-3 text-xs font-semibold tracking-wider uppercase",children:"On this page"}),n]})})}function Hr(e,t){return `
|
|
3
3
|
(() => {
|
|
4
4
|
const contentId = ${JSON.stringify(e)};
|
|
5
5
|
const itemIds = ${JSON.stringify(t.map(r=>r.id))};
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
scheduleUpdate();
|
|
75
75
|
});
|
|
76
76
|
})();
|
|
77
|
-
`}var le=be__namespace.forwardRef(({className:e,orientation:t="horizontal",decorative:r=true,...n},i)=>jsxRuntime.jsx(je__namespace.Root,{ref:i,decorative:r,orientation:t,className:f("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));le.displayName=je__namespace.Root.displayName;var bt={mdxOptions:{remarkPlugins:[kr__default.default,Ir__default.default],rehypePlugins:[Br,Or__default.default]}};function Br(){return e=>{xt(e);}}function xt(e){e.children&&(e.children=e.children.flatMap(t=>(xt(t),_r(t)?t.children?.filter(Ge)??[t]:[t])));}function _r(e){if(e.type!=="element"||e.tagName!=="p"||!e.children)return false;let t=e.children.filter(Ge);return t.length===1&&Er(t[0])}function Er(e){if(e?.type!=="element")return false;if(e.tagName==="img")return true;if(e.tagName!=="a"||!e.children)return false;let t=e.children.filter(Ge);return t.length===1&&t[0]?.tagName==="img"}function Ge(e){return e.type!=="text"||!!e.value?.trim()}function Vr(e){return `${Math.ceil(e/60)} min read`}function wt({article:e,className:t,navigation:r,basePath:n="/blog",theme:i,postArticleCta:o,relatedArticles:s=[],showShareLinks:a=true}){let u=k(n)||"/",l=Me(e.publishedAt,e.updatedAt),m=Vr(e.readingSeconds),p=$e(e.content),v=e.meta.canonicalUrl??L(u,e.slug),h=e.featuredImage;return jsxRuntime.jsxs("article",{style:U(i),className:f("article-page mx-auto max-w-6xl px-4 py-6 pb-12 sm:px-6 sm:py-8 sm:pb-16 lg:px-8 lg:py-12 lg:pb-24",t),children:[r?.backToHome&&jsxRuntime.jsx("header",{className:"mx-auto mb-8 max-w-4xl sm:mb-12 lg:mb-16",children:jsxRuntime.jsxs(K__default.default,{href:r.backToHome.url,className:"text-muted-foreground group focus-visible:ring-ring inline-flex touch-manipulation items-center space-x-2 rounded-md px-2 py-1 transition-colors hover:text-[var(--blog-accent)] focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none sm:space-x-3","aria-label":r.backToHome.label??"Return to blog",children:[jsxRuntime.jsx(lucideReact.ArrowLeft,{className:"h-4 w-4 transition-transform group-hover:-translate-x-1 sm:h-5 sm:w-5","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"text-sm font-medium sm:text-base",children:[jsxRuntime.jsx("span",{className:"hidden sm:inline",children:r.backToHome.label??"Back to all articles"}),jsxRuntime.jsx("span",{className:"sm:hidden",children:"Back"})]})]})}),jsxRuntime.jsxs("header",{className:"article-header mx-auto mb-6 max-w-4xl space-y-4 text-center sm:mb-8 sm:space-y-6 lg:mb-12 lg:space-y-8",children:[jsxRuntime.jsx("h1",{className:"article-title bg-linear-to-br from-[var(--blog-accent-hover)] via-[var(--blog-text-accent)] to-fuchsia-200 bg-clip-text px-4 text-2xl leading-tight font-light tracking-tight text-balance text-transparent sm:px-0 sm:text-3xl md:text-4xl lg:text-5xl xl:text-6xl",children:e.title}),e.excerpt&&jsxRuntime.jsx("p",{className:"article-excerpt text-muted-foreground mx-auto mt-6 max-w-[42rem] px-4 text-lg leading-relaxed text-balance sm:mt-8 sm:max-w-[46rem] sm:px-0 sm:text-xl md:max-w-[52rem] md:text-2xl lg:max-w-4xl lg:text-2xl",children:e.excerpt}),jsxRuntime.jsxs("div",{className:"article-meta text-muted-foreground flex flex-col items-center gap-2 text-sm sm:gap-3 sm:text-base",children:[e.author&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Author"}),jsxRuntime.jsx(yt,{author:e.author,size:"md"}),jsxRuntime.jsx("span",{className:"font-medium",children:e.author.name}),e.author.isGuest&&jsxRuntime.jsx(Ue,{variant:"outline",className:"text-xs",children:"Guest Author"})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-3 gap-y-1",children:[jsxRuntime.jsxs("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${l.publishedDateLabel}`,children:["Published ",l.publishedDateLabel]}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:l.publishedRelativeLabel}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:m})]}),l.isUpdated&&jsxRuntime.jsxs("time",{dateTime:e.updatedAt,className:"text-xs",children:["Updated ",l.updatedDateLabel]}),a&&jsxRuntime.jsx(xe,{title:e.title,url:v,size:"sm"}),jsxRuntime.jsx("div",{className:"bg-border h-px w-6 sm:w-8","aria-hidden":"true"}),(e.topics??[]).length>0?jsxRuntime.jsx("nav",{"aria-label":"Article topics",className:"flex flex-wrap justify-center gap-2",children:(e.topics??[]).map(d=>jsxRuntime.jsx(K__default.default,{href:L((r?.backToHome?.url??"/blog").replace(/\/$/,""),`topics/${d.slug}`),className:"rounded-full border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] px-3 py-1 text-xs font-medium text-[var(--blog-text-accent)] transition-colors hover:border-[var(--blog-text-accent)] hover:text-[var(--blog-text-accent-hover)]",children:d.name},d.id))}):jsxRuntime.jsxs("span",{className:"text-xs tracking-wider uppercase sm:text-sm",role:"text",children:["From ",e.site.name]})]})]}),h&&jsxRuntime.jsx("div",{className:"article-featured-image mx-auto my-8 aspect-[16/9] w-full max-w-4xl overflow-hidden rounded-3xl border border-[var(--blog-accent-border)] shadow-[0_24px_80px_rgb(168_85_247_/_0.14)] sm:my-12 lg:my-16",children:jsxRuntime.jsx(De__default.default,{src:h,alt:e.featuredImageAlt??`Featured image for ${e.title}`,className:"h-full w-full object-cover",width:800,height:450,priority:true})}),jsxRuntime.jsxs("div",{id:"article-content",className:"article-content mx-auto grid max-w-6xl grid-cols-1 gap-8 lg:grid-cols-[minmax(0,1fr)_14rem] lg:gap-12",children:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx(Ve,{items:p,contentId:"article-body",variant:"mobile"}),jsxRuntime.jsx("div",{id:"article-body",className:"prose prose-sm sm:prose-base lg:prose-lg xl:prose-xl prose-gray dark:prose-invert prose-headings:scroll-mt-20 prose-headings:font-light prose-headings:text-balance prose-headings:text-[var(--blog-text-accent)] prose-h1:text-2xl sm:prose-h1:text-3xl lg:prose-h1:text-4xl prose-h2:text-xl sm:prose-h2:text-2xl lg:prose-h2:text-3xl prose-h3:text-lg sm:prose-h3:text-xl lg:prose-h3:text-2xl prose-p:leading-relaxed prose-p:text-pretty prose-a:text-[var(--blog-text-accent)] prose-a:transition-colors hover:prose-a:text-[var(--blog-text-accent-hover)] max-w-none",children:jsxRuntime.jsx(rsc.MDXRemote,{source:e.content,options:bt,components:{img:ft}})})]}),jsxRuntime.jsx(Ve,{items:p,contentId:"article-body",variant:"desktop",showProgress:false})]}),e.author?.bio&&jsxRuntime.jsxs("div",{id:"about-author",className:"author-bio mx-auto mt-12 max-w-4xl",children:[jsxRuntime.jsx(le,{className:"mb-8"}),jsxRuntime.jsx(oe,{className:"border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsxs(ie,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-start sm:p-6",children:[jsxRuntime.jsx("div",{className:"shrink-0",children:jsxRuntime.jsx(yt,{author:e.author,size:"lg"})}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm font-medium",children:"Written by"}),jsxRuntime.jsxs("h2",{className:"text-foreground flex flex-wrap items-center gap-2 text-xl font-semibold",children:[e.author.name,e.author.isGuest&&jsxRuntime.jsx(Ue,{variant:"outline",className:"text-xs",children:"Guest Author"})]})]}),jsxRuntime.jsx(jr,{author:e.author})]}),jsxRuntime.jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.author.bio})]})]})})]}),((o??false)||a||s.length>0)&&jsxRuntime.jsxs("div",{className:"mx-auto mt-12 max-w-4xl space-y-8",children:[jsxRuntime.jsx(le,{}),o&&jsxRuntime.jsx(Fr,{cta:o}),a&&jsxRuntime.jsx(qr,{title:e.title,url:v}),s.length>0&&jsxRuntime.jsx(Xr,{articles:s.slice(0,3),basePath:u})]}),(!!r?.previousArticle||!!r?.nextArticle)&&jsxRuntime.jsxs("nav",{className:"article-nav mx-auto mt-12 max-w-4xl",children:[jsxRuntime.jsx(le,{className:"mb-8"}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[r?.previousArticle&&jsxRuntime.jsx(oe,{className:"group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsxs(K__default.default,{href:r.previousArticle.url,className:"block",children:[r.previousArticle.featuredImage&&jsxRuntime.jsx(ze,{src:r.previousArticle.featuredImage,alt:r.previousArticle.featuredImageAlt??`Featured image for ${r.previousArticle.title}`}),jsxRuntime.jsxs(ie,{className:"p-4",children:[jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"\u2190 Previous Article"}),jsxRuntime.jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.previousArticle.title})]})]})}),r?.nextArticle&&jsxRuntime.jsx(oe,{className:f("group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",!r?.previousArticle&&"md:col-start-2"),children:jsxRuntime.jsxs(K__default.default,{href:r.nextArticle.url,className:"block",children:[r.nextArticle.featuredImage&&jsxRuntime.jsx(ze,{src:r.nextArticle.featuredImage,alt:r.nextArticle.featuredImageAlt??`Featured image for ${r.nextArticle.title}`}),jsxRuntime.jsxs(ie,{className:"p-4 md:text-right",children:[jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"Next Article \u2192"}),jsxRuntime.jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.nextArticle.title})]})]})})]})]}),(()=>{let d=ne(_e(e,{pathPrefix:u}));return jsxRuntime.jsx("script",{type:d.type,dangerouslySetInnerHTML:d.dangerouslySetInnerHTML})})()]})}function yt({author:e,size:t}){let r=t==="lg"?"h-12 w-12 text-base":"h-9 w-9 text-sm",n=zr(e.name);return e.avatarUrl?jsxRuntime.jsx(De__default.default,{src:e.avatarUrl,alt:e.name,width:t==="lg"?48:36,height:t==="lg"?48:36,className:f("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsxRuntime.jsx("span",{className:f("bg-muted text-muted-foreground inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function jr({author:e}){let t=Gr(e);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:t.map(r=>jsxRuntime.jsx("a",{href:r.href,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,"aria-label":`${e.name} ${r.label}`,className:"text-muted-foreground hover:bg-background/60 hover:text-foreground inline-flex size-7 items-center justify-center rounded-full transition-colors",children:r.icon},r.key))})}function Gr(e){let t=e.socialLinks;return t?[t.website?{key:"website",href:t.website,label:"website",external:true,icon:jsxRuntime.jsx(lucideReact.Globe,{className:"size-4","aria-hidden":"true"})}:void 0,t.x?{key:"x",href:t.x,label:"on X",external:true,icon:jsxRuntime.jsx(fa6.FaXTwitter,{className:"size-4","aria-hidden":"true"})}:void 0,t.linkedin?{key:"linkedin",href:t.linkedin,label:"on LinkedIn",external:true,icon:jsxRuntime.jsx(fa6.FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}:void 0,t.github?{key:"github",href:t.github,label:"on GitHub",external:true,icon:jsxRuntime.jsx(fa6.FaGithub,{className:"size-4","aria-hidden":"true"})}:void 0,t.email?{key:"email",href:`mailto:${t.email}`,label:"email",external:false,icon:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})}:void 0].filter(n=>!!n):[]}function zr(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function Fr({cta:e}){return jsxRuntime.jsx("div",{className:"rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] p-5 sm:p-6",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("h2",{className:"text-foreground text-xl font-semibold",children:e.title}),e.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.description})]}),jsxRuntime.jsxs(K__default.default,{href:e.href,className:"inline-flex shrink-0 items-center justify-center gap-2 rounded-full bg-[var(--blog-accent)] px-4 py-2 text-sm font-semibold text-white transition-opacity hover:opacity-90",children:[e.label,jsxRuntime.jsx(lucideReact.ArrowUpRight,{className:"size-4","aria-hidden":"true"})]})]})})}function qr({title:e,url:t}){let r=encodeURIComponent(e),n=encodeURIComponent(t);return jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2 sm:gap-3",children:[jsxRuntime.jsx(xe,{title:e,url:t,size:"sm"}),jsxRuntime.jsx("a",{href:`https://x.com/intent/tweet?text=${r}&url=${n}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Share on X",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(fa6.FaXTwitter,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsx("a",{href:`https://www.linkedin.com/sharing/share-offsite/?url=${n}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Share on LinkedIn",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(fa6.FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsx("a",{href:`mailto:?subject=${r}&body=${n}`,"aria-label":"Share by email",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})})]})}function Xr({articles:e,basePath:t}){return jsxRuntime.jsxs("section",{className:"space-y-4","aria-labelledby":"related-articles-title",children:[jsxRuntime.jsx("h2",{id:"related-articles-title",className:"text-xl font-semibold",children:"You might also like"}),jsxRuntime.jsx("div",{className:"grid gap-4 md:grid-cols-3",children:e.map(r=>jsxRuntime.jsxs(K__default.default,{href:L(t,r.slug),className:"group border-border overflow-hidden rounded-2xl border transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)] hover:no-underline",children:[r.featuredImage&&jsxRuntime.jsx(ze,{src:r.featuredImage,alt:r.featuredImageAlt??`Featured image for ${r.title}`}),jsxRuntime.jsxs("div",{className:"p-4",children:[jsxRuntime.jsx("h3",{className:"text-foreground line-clamp-3 font-semibold transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.title}),r.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:r.excerpt})]})]},r.id))})]})}function ze({src:e,alt:t}){return jsxRuntime.jsx("div",{className:"border-border aspect-[16/9] overflow-hidden border-b bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(De__default.default,{src:e,alt:t,width:480,height:270,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"})})}function Wr(e,t="/blog"){let r=e.meta.title??e.title,n=e.meta.description??e.excerpt,i=e.meta.canonicalUrl??`${e.site.domain}${L(t,e.slug)}`,o=e.meta.ogImage??e.featuredImage;return {title:r,description:n,keywords:e.meta.keywords.join(", "),authors:e.author?[{name:e.author.name}]:void 0,openGraph:{title:r,description:n,type:"article",url:i,images:o?[{url:o,alt:e.featuredImageAlt??r}]:void 0,publishedTime:e.publishedAt,modifiedTime:e.updatedAt,authors:e.author?[e.author.name]:void 0,siteName:e.site.name},twitter:{card:"summary_large_image",title:r,description:n,images:o?[o]:void 0},alternates:{canonical:i}}}function Kr(e){let t=e.topics??[];return t.find(r=>r.isPrimary)??t[0]??null}function qe(e){let t=new Map;for(let r of e)for(let n of r.topics??[])t.has(n.slug)||t.set(n.slug,n);return Array.from(t.values()).sort((r,n)=>r.name.localeCompare(n.name))}function Xe(e,t){let r=e.filter(i=>(i.topics??[]).some(o=>o.slug===t));if(r.length===0)return null;let n=r.flatMap(i=>i.topics??[]).find(i=>i.slug===t)??null;return n?{topic:n,articles:r}:null}function Qr({articles:e,basePath:t="/blog",title:r="Topics",description:n="Browse articles by topic.",className:i,theme:o}){let s=k(t)||"/",a=qe(e);return jsxRuntime.jsxs("main",{style:U(o),className:f("blog-topics-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",i),children:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(K__default.default,{href:s,className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all articles"}),jsxRuntime.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-balance sm:text-5xl",children:r}),jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),a.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No topics have published articles yet."}):jsxRuntime.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:a.map(u=>{let l=e.filter(m=>(m.topics??[]).some(p=>p.slug===u.slug)).length;return jsxRuntime.jsxs(K__default.default,{href:L(s,`topics/${u.slug}`),className:"group rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] p-5 transition hover:border-[var(--blog-accent)] hover:no-underline",children:[jsxRuntime.jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold transition-colors",children:u.name}),u.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:u.description}),jsxRuntime.jsxs("p",{className:"text-muted-foreground mt-4 text-sm",children:[l," ",l===1?"article":"articles"]})]},u.slug)})})]})}function Zr({articles:e,topicSlug:t,basePath:r="/blog",className:n,theme:i}){let o=k(r)||"/",s=Xe(e,t);return jsxRuntime.jsxs("main",{style:U(i),className:f("blog-topic-archive-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",n),children:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(K__default.default,{href:L(o,"topics"),className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all topics"}),jsxRuntime.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-balance sm:text-5xl",children:s?.topic.name??"Topic not found"}),s?.topic.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:s.topic.description})]}),s?jsxRuntime.jsx("div",{className:"grid gap-5 md:grid-cols-2",children:s.articles.map(a=>jsxRuntime.jsx(en,{article:a,topic:s.topic,basePath:o},a.id))}):jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No published articles were found for this topic."})]})}function en({article:e,topic:t,basePath:r}){let n=L(r,e.slug),i=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxRuntime.jsxs(K__default.default,{href:n,className:"group overflow-hidden rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] transition hover:border-[var(--blog-accent)] hover:no-underline",children:[e.featuredImage&&jsxRuntime.jsx("div",{className:"relative aspect-[16/9] overflow-hidden",children:jsxRuntime.jsx(De__default.default,{src:e.featuredImage,alt:e.featuredImageAlt??e.title,width:640,height:360,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})}),jsxRuntime.jsxs("div",{className:"space-y-3 p-5",children:[jsxRuntime.jsx("span",{className:"inline-flex rounded-full border border-[var(--blog-accent-border)] px-2.5 py-1 text-xs font-medium text-[var(--blog-text-accent)]",children:t.name}),jsxRuntime.jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold text-balance transition-colors",children:e.title}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:e.excerpt}),jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm",children:i})]})]})}function We(e){let t=e.headers.get("Authorization");if(!t)return null;let n=/^Bearer\s+(.+)$/i.exec(t);if(n?.[1])return n[1];let o=/^Token\s+(.+)$/i.exec(t);return o?.[1]?o[1]:null}var ve=class{validApiKeys;constructor(t){this.validApiKeys=new Set(t);}async validateToken(t){return t?.trim()?this.validApiKeys.has(t)?{valid:true,context:{tokenHash:this.hashToken(t)}}:{valid:false,errorCode:"invalid"}:{valid:false,errorCode:"missing"}}extractToken=t=>We(t);hashToken(t){return t.substring(0,8)+"..."}},J=class extends ve{constructor(t="BLOG_PLATFORM_API_KEYS"){let r=process.env[t];!r&&t==="BLOG_PLATFORM_API_KEYS"&&(r=process.env.BLOG_AUTH_TOKEN);let n=r?r.split(",").map(i=>i.trim()).filter(Boolean):[];n.length===0&&console.warn(`\u26A0\uFE0F No API keys found in environment variable ${t}${t==="BLOG_PLATFORM_API_KEYS"?" (set BLOG_PLATFORM_API_KEYS or BLOG_AUTH_TOKEN)":""}. Authentication will fail for all requests.`),super(n);}},ce=class{async validateToken(){return {valid:true,context:{development:true}}}extractToken(){return "development-mode"}},Pe=class{hasWarned=false;async validateToken(t){return this.hasWarned||(console.error("\u274C SECURITY WARNING: Blog platform authentication not initialized! All requests will be rejected. Call initBlogPlatform() to configure authentication."),this.hasWarned=true),{valid:false,errorCode:"invalid"}}};function tn(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??=new Pe,globalThis.__BLOG_PLATFORM_AUTH_CONFIG__}function Ae(e){globalThis.__BLOG_PLATFORM_AUTH_CONFIG__=e;}function Ke(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??tn()}function rn(e){Ae(new J(e));}async function $(e){let t=Ke(),r=t.extractToken?t.extractToken(e):We(e);if(!r)return {authenticated:false,result:{valid:false,errorCode:"missing"},token:null};let n=await t.validateToken(r);return {authenticated:n.valid,result:n,token:r}}function nn(e,t=""){let n=Ke().errorMessages??{},i,o;switch(e.errorCode){case "missing":i=n.missing??"Authentication token is required",o="PUB005";break;case "expired":i=n.expired??"Authentication token has expired",o="PUB005";break;default:i=n.invalid??"Invalid authentication credentials",o="PUB005";break}return {success:false,error:{code:o,message:i,details:{authError:e.errorCode??"invalid"}},idempotencyKey:t}}async function V(e){let t=await $(e);return t.authenticated?{authenticated:true,context:t.result.context}:{authenticated:false,error:nn(t.result)}}function on(){let e=process.env.SKIP_BLOG_PLATFORM_AUTH;return e==="true"||e==="1"||process.env.NODE_ENV==="test"}var we=class{articles=new Map;operations=new Map;async saveArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if(Array.from(this.articles.values()).some(s=>s.id===t.id))return n}else return n;if(this.articles.has(t.slug)){let o={success:false,error:{code:"PUB003",message:"This URL is already in use. Please choose another."},idempotencyKey:r};return await this.storeOperationResult(r,o),o}this.articles.set(t.slug,t);let i={success:true,url:`/${t.slug}`,platformPostId:t.id,publishedAt:t.publishedAt,idempotencyKey:r};return await this.storeOperationResult(r,i),i}async getArticle(t){return this.articles.get(t)??null}async listArticles(t={}){let{limit:r=10,offset:n=0,sortBy:i="publishedAt",order:o="desc"}=t,s=Array.from(this.articles.values());return s.sort((u,l)=>{let m=new Date(u[i]).getTime(),p=new Date(l[i]).getTime();return o==="desc"?p-m:m-p}),{articles:s.slice(n,n+r),total:s.length}}async removeArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if(!this.articles.has(t))return n}else return n;if(!this.articles.has(t)){let o={success:false,error:{code:"PUB007",message:"Article not found"},idempotencyKey:r};return await this.storeOperationResult(r,o),o}this.articles.delete(t);let i={success:true,idempotencyKey:r};return await this.storeOperationResult(r,i),i}async checkIdempotency(t){return this.operations.get(t)??null}async storeOperationResult(t,r){this.operations.set(t,r);}};function sn(){let e=globalThis;if(e.__BLOG_PLATFORM_STORAGE_WARNED__)return;e.__BLOG_PLATFORM_STORAGE_WARNED__=true;let t="Blog platform: No storage provider configured. Falling back to in-memory storage (data is not persisted).";process.env.NODE_ENV==="production"?console.error(`${t} Call initBlogPlatform({ storage: /* your persistent adapter */ }) to avoid data loss.`):console.warn(t);}function an(){let e=globalThis;e.__BLOG_PLATFORM_STORAGE__||(sn(),e.__BLOG_PLATFORM_STORAGE__=new we);let t=e.__BLOG_PLATFORM_STORAGE__;if(!t)throw new Error("Blog platform storage not initialized");return t}function j(){return an()}function Je(e){let t=globalThis;t.__BLOG_PLATFORM_STORAGE__=e;}function cn(){return globalThis.__BLOG_PLATFORM_RATE_LIMITER__??null}function un(e){let t=globalThis;t.__BLOG_PLATFORM_RATE_LIMITER__=e;}function Se(e){let{redisUrl:t,redisToken:r,requestsPerMinute:n=5,keyPrefix:i="blog-platform-ratelimit",analytics:o=true}=e,s=new redis.Redis({url:t,token:r}),a=new ratelimit.Ratelimit({redis:s,analytics:o,prefix:i,limiter:ratelimit.Ratelimit.slidingWindow(n,"1m")});un(a);}function Ye(){let e=process.env.UPSTASH_REDIS_REST_URL,t=process.env.UPSTASH_REDIS_REST_TOKEN;if(!e||!t){console.warn("Blog platform: No Upstash Redis configuration found. Rate limiting disabled.");return}Se({redisUrl:e,redisToken:t}),console.log("Blog platform: Rate limiting configured (5 requests per minute per token)");}async function Rt(e){let t=cn();if(!t)return console.warn("Blog platform: Rate limiter not configured. All requests allowed."),{success:true,remaining:999,reset:Date.now()+6e4,limit:5,count:0};try{let r=await t.limit(e);return {success:r.success,remaining:r.remaining,reset:r.reset,limit:r.limit,count:r.limit-r.remaining}}catch(r){return console.error("Blog platform: Rate limit check failed:",r),{success:true,remaining:0,reset:Date.now()+6e4,limit:5,count:0}}}function Nt(e,t=""){let r=Math.ceil((e.reset-Date.now())/6e4);return {success:false,error:{code:"PUB011",message:`Rate limit exceeded. You can make ${e.limit} requests per minute. Try again in ${r} minute(s).`,details:{rateLimit:e}},idempotencyKey:t}}async function D(e,t=""){let r=await Rt(e);return r.success?{allowed:true,rateLimitResult:r}:{allowed:false,errorResponse:Nt(r,t)}}function T(e){return {"X-RateLimit-Limit":e.limit.toString(),"X-RateLimit-Remaining":e.remaining.toString(),"X-RateLimit-Reset":e.reset.toString(),"Retry-After":Math.ceil((e.reset-Date.now())/1e3).toString()}}function Re(e){let{auth:t,storage:r,rateLimit:n,autoRateLimit:i=true}=e;if(!t)throw new Error(`Blog platform initialization failed: 'auth' is required.
|
|
77
|
+
`}var Q=Ne__namespace.forwardRef(({className:e,orientation:t="horizontal",decorative:r=true,...n},i)=>jsxRuntime.jsx(Ke__namespace.Root,{ref:i,decorative:r,orientation:t,className:f("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));Q.displayName=Ke__namespace.Root.displayName;var St={mdxOptions:{remarkPlugins:[Vr__default.default,Gr__default.default],rehypePlugins:[qr,Fr__default.default]}};function qr(){return e=>{Nt(e);}}function Nt(e){e.children&&(e.children=e.children.flatMap(t=>(Nt(t),Xr(t)?t.children?.filter(Je)??[t]:[t])));}function Xr(e){if(e.type!=="element"||e.tagName!=="p"||!e.children)return false;let t=e.children.filter(Je);return t.length===1&&Wr(t[0])}function Wr(e){if(e?.type!=="element")return false;if(e.tagName==="img")return true;if(e.tagName!=="a"||!e.children)return false;let t=e.children.filter(Je);return t.length===1&&t[0]?.tagName==="img"}function Je(e){return e.type!=="text"||!!e.value?.trim()}function en(e){return `${Math.ceil(e/60)} min read`}function kt({article:e,className:t,navigation:r,basePath:n="/blog",theme:i,postArticleCta:o,relatedArticles:a=[],showShareLinks:s=true}){let l=T(n)||"/",c=Ve(e.publishedAt,e.updatedAt),d=en(e.readingSeconds),m=Fe(e.content),x=e.meta.canonicalUrl??C(l,e.slug),h=e.featuredImage;return jsxRuntime.jsxs("article",{style:_(i),className:f("article-page mx-auto max-w-6xl px-4 py-6 pb-12 sm:px-6 sm:py-8 sm:pb-16 lg:px-8 lg:py-12 lg:pb-24",t),children:[r?.backToHome&&jsxRuntime.jsx("header",{className:"mx-auto mb-8 max-w-4xl sm:mb-12 lg:mb-16",children:jsxRuntime.jsxs(F__default.default,{href:r.backToHome.url,className:"text-muted-foreground group focus-visible:ring-ring inline-flex touch-manipulation items-center space-x-2 rounded-md px-2 py-1 transition-colors hover:text-[var(--blog-accent)] focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none sm:space-x-3","aria-label":r.backToHome.label??"Return to blog",children:[jsxRuntime.jsx(lucideReact.ArrowLeft,{className:"h-4 w-4 transition-transform group-hover:-translate-x-1 sm:h-5 sm:w-5","aria-hidden":"true"}),jsxRuntime.jsxs("span",{className:"text-sm font-medium sm:text-base",children:[jsxRuntime.jsx("span",{className:"hidden sm:inline",children:r.backToHome.label??"Back to all articles"}),jsxRuntime.jsx("span",{className:"sm:hidden",children:"Back"})]})]})}),jsxRuntime.jsxs("header",{className:"article-header mx-auto mb-6 max-w-4xl space-y-4 text-center sm:mb-8 sm:space-y-6 lg:mb-12 lg:space-y-8",children:[jsxRuntime.jsx("h1",{className:"article-title bg-linear-to-br from-[var(--blog-accent-hover)] via-[var(--blog-text-accent)] to-fuchsia-200 bg-clip-text px-4 text-2xl leading-tight font-light tracking-tight text-balance text-transparent sm:px-0 sm:text-3xl md:text-4xl lg:text-5xl xl:text-6xl",children:e.title}),e.excerpt&&jsxRuntime.jsx("p",{className:"article-excerpt text-muted-foreground mx-auto mt-6 max-w-[42rem] px-4 text-lg leading-relaxed text-balance sm:mt-8 sm:max-w-[46rem] sm:px-0 sm:text-xl md:max-w-[52rem] md:text-2xl lg:max-w-4xl lg:text-2xl",children:e.excerpt}),jsxRuntime.jsxs("div",{className:"article-meta text-muted-foreground flex flex-col items-center gap-2 text-sm sm:gap-3 sm:text-base",children:[e.author&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Author"}),jsxRuntime.jsxs(F__default.default,{href:R(l,e.author.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsxRuntime.jsx(Rt,{author:e.author,size:"md"}),e.author.name]}),e.author.isGuest&&jsxRuntime.jsx(de,{variant:"outline",className:"text-xs",children:"Guest Author"})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-3 gap-y-1",children:[jsxRuntime.jsxs("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${c.publishedDateLabel}`,children:["Published ",c.publishedDateLabel]}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:c.publishedRelativeLabel}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:d})]}),c.isUpdated&&jsxRuntime.jsxs("time",{dateTime:e.updatedAt,className:"text-xs",children:["Updated ",c.updatedDateLabel]}),s&&jsxRuntime.jsx(Re,{title:e.title,url:x,size:"sm"}),jsxRuntime.jsx("div",{className:"bg-border h-px w-6 sm:w-8","aria-hidden":"true"}),(e.topics??[]).length>0?jsxRuntime.jsx("nav",{"aria-label":"Article topics",className:"flex flex-wrap justify-center gap-2",children:(e.topics??[]).map(p=>jsxRuntime.jsx(F__default.default,{href:C((r?.backToHome?.url??"/blog").replace(/\/$/,""),`topics/${p.slug}`),className:"rounded-full border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] px-3 py-1 text-xs font-medium text-[var(--blog-text-accent)] transition-colors hover:border-[var(--blog-text-accent)] hover:text-[var(--blog-text-accent-hover)]",children:p.name},p.id))}):jsxRuntime.jsxs("span",{className:"text-xs tracking-wider uppercase sm:text-sm",role:"text",children:["From ",e.site.name]})]})]}),h&&jsxRuntime.jsx("div",{className:"article-featured-image mx-auto my-8 aspect-[16/9] w-full max-w-4xl overflow-hidden rounded-3xl border border-[var(--blog-accent-border)] shadow-[0_24px_80px_rgb(168_85_247_/_0.14)] sm:my-12 lg:my-16",children:jsxRuntime.jsx(qe__default.default,{src:h,alt:e.featuredImageAlt??`Featured image for ${e.title}`,className:"h-full w-full object-cover",width:800,height:450,priority:true})}),jsxRuntime.jsxs("div",{id:"article-content",className:"article-content mx-auto grid max-w-6xl grid-cols-1 gap-8 lg:grid-cols-[minmax(0,1fr)_14rem] lg:gap-12",children:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx(We,{items:m,contentId:"article-body",variant:"mobile"}),jsxRuntime.jsx("div",{id:"article-body",className:"prose prose-sm sm:prose-base lg:prose-lg xl:prose-xl prose-gray dark:prose-invert prose-headings:scroll-mt-20 prose-headings:font-light prose-headings:text-balance prose-headings:text-[var(--blog-text-accent)] prose-h1:text-2xl sm:prose-h1:text-3xl lg:prose-h1:text-4xl prose-h2:text-xl sm:prose-h2:text-2xl lg:prose-h2:text-3xl prose-h3:text-lg sm:prose-h3:text-xl lg:prose-h3:text-2xl prose-p:leading-relaxed prose-p:text-pretty prose-a:text-[var(--blog-text-accent)] prose-a:transition-colors hover:prose-a:text-[var(--blog-text-accent-hover)] max-w-none",children:jsxRuntime.jsx(rsc.MDXRemote,{source:e.content,options:St,components:{img:At}})})]}),jsxRuntime.jsx(We,{items:m,contentId:"article-body",variant:"desktop",showProgress:false})]}),e.author?.bio&&jsxRuntime.jsxs("div",{id:"about-author",className:"author-bio mx-auto mt-12 max-w-4xl",children:[jsxRuntime.jsx(Q,{className:"mb-8"}),jsxRuntime.jsx(me,{className:"border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsxs(pe,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-start sm:p-6",children:[jsxRuntime.jsx("div",{className:"shrink-0",children:jsxRuntime.jsx(Rt,{author:e.author,size:"lg"})}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm font-medium",children:"Written by"}),jsxRuntime.jsxs("h2",{className:"text-foreground flex flex-wrap items-center gap-2 text-xl font-semibold",children:[jsxRuntime.jsx(F__default.default,{href:R(l,e.author.slug),className:"transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:e.author.name}),e.author.isGuest&&jsxRuntime.jsx(de,{variant:"outline",className:"text-xs",children:"Guest Author"})]})]}),jsxRuntime.jsx(tn,{author:e.author})]}),jsxRuntime.jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.author.bio})]})]})})]}),((o??false)||s||a.length>0)&&jsxRuntime.jsxs("div",{className:"mx-auto mt-12 max-w-4xl space-y-8",children:[jsxRuntime.jsx(Q,{}),o&&jsxRuntime.jsx(on,{cta:o}),s&&jsxRuntime.jsx(an,{title:e.title,url:x}),a.length>0&&jsxRuntime.jsx(sn,{articles:a.slice(0,3),basePath:l})]}),(!!r?.previousArticle||!!r?.nextArticle)&&jsxRuntime.jsxs("nav",{className:"article-nav mx-auto mt-12 max-w-4xl",children:[jsxRuntime.jsx(Q,{className:"mb-8"}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[r?.previousArticle&&jsxRuntime.jsx(me,{className:"group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsxs(F__default.default,{href:r.previousArticle.url,className:"block",children:[r.previousArticle.featuredImage&&jsxRuntime.jsx(Ye,{src:r.previousArticle.featuredImage,alt:r.previousArticle.featuredImageAlt??`Featured image for ${r.previousArticle.title}`}),jsxRuntime.jsxs(pe,{className:"p-4",children:[jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"\u2190 Previous Article"}),jsxRuntime.jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.previousArticle.title})]})]})}),r?.nextArticle&&jsxRuntime.jsx(me,{className:f("group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",!r?.previousArticle&&"md:col-start-2"),children:jsxRuntime.jsxs(F__default.default,{href:r.nextArticle.url,className:"block",children:[r.nextArticle.featuredImage&&jsxRuntime.jsx(Ye,{src:r.nextArticle.featuredImage,alt:r.nextArticle.featuredImageAlt??`Featured image for ${r.nextArticle.title}`}),jsxRuntime.jsxs(pe,{className:"p-4 md:text-right",children:[jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"Next Article \u2192"}),jsxRuntime.jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.nextArticle.title})]})]})})]})]}),(()=>{let p=J(ze(e,{pathPrefix:l}));return jsxRuntime.jsx("script",{type:p.type,dangerouslySetInnerHTML:p.dangerouslySetInnerHTML})})()]})}function Rt({author:e,size:t}){let r=t==="lg"?"h-12 w-12 text-base":"h-9 w-9 text-sm",n=nn(e.name);return e.avatarUrl?jsxRuntime.jsx(qe__default.default,{src:e.avatarUrl,alt:e.name,width:t==="lg"?48:36,height:t==="lg"?48:36,className:f("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsxRuntime.jsx("span",{className:f("bg-muted text-muted-foreground inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function tn({author:e}){let t=rn(e);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:t.map(r=>jsxRuntime.jsx("a",{href:r.href,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,"aria-label":`${e.name} ${r.label}`,className:"text-muted-foreground hover:bg-background/60 hover:text-foreground inline-flex size-7 items-center justify-center rounded-full transition-colors",children:r.icon},r.key))})}function rn(e){let t=e.socialLinks;return t?[t.website?{key:"website",href:t.website,label:"website",external:true,icon:jsxRuntime.jsx(lucideReact.Globe,{className:"size-4","aria-hidden":"true"})}:void 0,t.x?{key:"x",href:t.x,label:"on X",external:true,icon:jsxRuntime.jsx(fa6.FaXTwitter,{className:"size-4","aria-hidden":"true"})}:void 0,t.linkedin?{key:"linkedin",href:t.linkedin,label:"on LinkedIn",external:true,icon:jsxRuntime.jsx(fa6.FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}:void 0,t.github?{key:"github",href:t.github,label:"on GitHub",external:true,icon:jsxRuntime.jsx(fa6.FaGithub,{className:"size-4","aria-hidden":"true"})}:void 0,t.email?{key:"email",href:`mailto:${t.email}`,label:"email",external:false,icon:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})}:void 0].filter(n=>!!n):[]}function nn(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function on({cta:e}){return jsxRuntime.jsx("div",{className:"rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] p-5 sm:p-6",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("h2",{className:"text-foreground text-xl font-semibold",children:e.title}),e.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.description})]}),jsxRuntime.jsxs(F__default.default,{href:e.href,className:"inline-flex shrink-0 items-center justify-center gap-2 rounded-full bg-[var(--blog-accent)] px-4 py-2 text-sm font-semibold text-white transition-opacity hover:opacity-90",children:[e.label,jsxRuntime.jsx(lucideReact.ArrowUpRight,{className:"size-4","aria-hidden":"true"})]})]})})}function an({title:e,url:t}){let r=encodeURIComponent(e),n=encodeURIComponent(t);return jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2 sm:gap-3",children:[jsxRuntime.jsx(Re,{title:e,url:t,size:"sm"}),jsxRuntime.jsx("a",{href:`https://x.com/intent/tweet?text=${r}&url=${n}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Share on X",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(fa6.FaXTwitter,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsx("a",{href:`https://www.linkedin.com/sharing/share-offsite/?url=${n}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Share on LinkedIn",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(fa6.FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsx("a",{href:`mailto:?subject=${r}&body=${n}`,"aria-label":"Share by email",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})})]})}function sn({articles:e,basePath:t}){return jsxRuntime.jsxs("section",{className:"space-y-4","aria-labelledby":"related-articles-title",children:[jsxRuntime.jsx("h2",{id:"related-articles-title",className:"text-xl font-semibold",children:"You might also like"}),jsxRuntime.jsx("div",{className:"grid gap-4 md:grid-cols-3",children:e.map(r=>jsxRuntime.jsxs(F__default.default,{href:C(t,r.slug),className:"group border-border overflow-hidden rounded-2xl border transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)] hover:no-underline",children:[r.featuredImage&&jsxRuntime.jsx(Ye,{src:r.featuredImage,alt:r.featuredImageAlt??`Featured image for ${r.title}`}),jsxRuntime.jsxs("div",{className:"p-4",children:[jsxRuntime.jsx("h3",{className:"text-foreground line-clamp-3 font-semibold transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.title}),r.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:r.excerpt})]})]},r.id))})]})}function Ye({src:e,alt:t}){return jsxRuntime.jsx("div",{className:"border-border aspect-[16/9] overflow-hidden border-b bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(qe__default.default,{src:e,alt:t,width:480,height:270,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"})})}function ln(e,t="/blog"){let r=e.meta.title??e.title,n=e.meta.description??e.excerpt,i=e.meta.canonicalUrl??`${e.site.domain}${C(t,e.slug)}`,o=e.meta.ogImage??e.featuredImage;return {title:r,description:n,keywords:e.meta.keywords.join(", "),authors:e.author?[{name:e.author.name}]:void 0,openGraph:{title:r,description:n,type:"article",url:i,images:o?[{url:o,alt:e.featuredImageAlt??r}]:void 0,publishedTime:e.publishedAt,modifiedTime:e.updatedAt,authors:e.author?[e.author.name]:void 0,siteName:e.site.name},twitter:{card:"summary_large_image",title:r,description:n,images:o?[o]:void 0},alternates:{canonical:i}}}function Ot({author:e,articles:t,site:r,className:n,basePath:i="/blog",theme:o,pagination:a,navigation:s}){let l=T(i)||"/",c=s?.backToHome?.url??l,d=R(l,e.slug),m=a?.totalItems??t.length,x=J(Se(e,{pathPrefix:l}));return jsxRuntime.jsxs("main",{style:_(o),className:f("author-page mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",n),children:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-8 sm:mb-14",children:[jsxRuntime.jsxs(F__default.default,{href:c,className:"text-muted-foreground group focus-visible:ring-ring inline-flex items-center gap-2 rounded-md px-2 py-1 text-sm font-medium transition-colors hover:text-[var(--blog-accent)] focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",children:[jsxRuntime.jsx(lucideReact.ArrowLeft,{className:"size-4 transition-transform group-hover:-translate-x-1","aria-hidden":"true"}),s?.backToHome?.label??"Back to all articles"]}),jsxRuntime.jsxs("div",{className:"grid gap-6 sm:grid-cols-[auto_minmax(0,1fr)] sm:items-center",children:[jsxRuntime.jsx(hn,{author:e}),jsxRuntime.jsxs("div",{className:"min-w-0 space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.isGuest&&jsxRuntime.jsx(de,{variant:"outline",className:"text-xs",children:"Guest Author"})}),jsxRuntime.jsx("h1",{className:"text-foreground text-4xl leading-tight font-semibold text-balance sm:text-5xl",children:e.name})]}),e.bio&&jsxRuntime.jsx("p",{className:"text-muted-foreground max-w-3xl text-lg leading-relaxed text-pretty",children:e.bio}),jsxRuntime.jsx(pn,{author:e})]})]})]}),jsxRuntime.jsx(Q,{className:"mb-8"}),jsxRuntime.jsxs("section",{"aria-labelledby":"author-articles-title",className:"space-y-6",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap items-end justify-between gap-3",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h2",{id:"author-articles-title",className:"text-foreground text-2xl font-semibold",children:["Articles by ",e.name]}),jsxRuntime.jsxs("p",{className:"text-muted-foreground mt-1 text-sm",children:[m," ",m===1?"article":"articles"," on ",r.name]})]})}),t.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground border-border rounded-2xl border p-6",children:"This author does not have any published articles yet."}):jsxRuntime.jsx("div",{className:"divide-border divide-y",children:t.map(h=>jsxRuntime.jsx(fn,{article:h,basePath:l},h.id))}),a&&a.totalPages>1&&jsxRuntime.jsx("div",{className:"pt-4",children:jsxRuntime.jsx(ee,{currentPage:a.currentPage,totalPages:a.totalPages,baseUrl:a.baseUrl??d,className:"justify-center"})})]}),jsxRuntime.jsx("script",{type:x.type,dangerouslySetInnerHTML:x.dangerouslySetInnerHTML})]})}function pn({author:e}){let t=gn(e);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-2","aria-label":"Author links",children:t.map(r=>jsxRuntime.jsx("a",{href:r.href,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,"aria-label":r.ariaLabel,className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:r.icon},r.label))})}function gn(e){let t=e.socialLinks;return t?[t.website?{href:t.website,label:"website",ariaLabel:`${e.name}'s website`,external:true,icon:jsxRuntime.jsx(lucideReact.Globe,{className:"size-4","aria-hidden":"true"})}:null,t.x??t.twitter?{href:t.x??t.twitter??"",label:"x",ariaLabel:`${e.name} on X`,external:true,icon:jsxRuntime.jsx("span",{className:"text-sm font-semibold","aria-hidden":"true",children:"X"})}:null,t.linkedin?{href:t.linkedin,label:"linkedin",ariaLabel:`${e.name} on LinkedIn`,external:true,icon:jsxRuntime.jsx("span",{className:"text-sm font-bold","aria-hidden":"true",children:"in"})}:null,t.github?{href:t.github,label:"github",ariaLabel:`${e.name} on GitHub`,external:true,icon:jsxRuntime.jsx("span",{className:"text-xs font-bold","aria-hidden":"true",children:"GH"})}:null,t.email?{href:`mailto:${t.email}`,label:"email",ariaLabel:`Email ${e.name}`,external:false,icon:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})}:null].filter(r=>r!==null):[]}function fn({article:e,basePath:t}){let r=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxRuntime.jsx("article",{className:"py-6 first:pt-0 last:pb-0",children:jsxRuntime.jsxs(F__default.default,{href:C(t,e.slug),className:"group grid gap-4 hover:no-underline sm:grid-cols-[minmax(0,1fr)_12rem] sm:items-start",children:[jsxRuntime.jsxs("div",{className:"min-w-0 space-y-3",children:[jsxRuntime.jsx("h3",{className:"text-xl leading-tight font-semibold text-balance transition-colors group-hover:text-[var(--blog-text-accent)]",children:e.title}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 leading-relaxed",children:e.excerpt}),jsxRuntime.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[jsxRuntime.jsx("time",{dateTime:e.publishedAt,children:r}),jsxRuntime.jsx("span",{"aria-hidden":"true",children:"\u2022"}),jsxRuntime.jsxs("span",{children:[Math.ceil(e.readingSeconds/60)," min read"]})]})]}),e.featuredImage&&jsxRuntime.jsx("div",{className:"border-border relative aspect-[16/10] overflow-hidden rounded-xl border bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(qe__default.default,{src:e.featuredImage,alt:e.featuredImageAlt??`Featured image for ${e.title}`,width:320,height:200,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"})})]})})}function hn({author:e}){return e.avatarUrl?jsxRuntime.jsx(qe__default.default,{src:e.avatarUrl,alt:e.name,width:128,height:128,className:"size-28 rounded-full border border-[var(--blog-accent-border)] object-cover sm:size-32",priority:true}):jsxRuntime.jsx("span",{className:"bg-muted text-muted-foreground inline-flex size-28 items-center justify-center rounded-full text-3xl font-semibold sm:size-32",children:bn(e.name)})}function bn(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function xn(e,t,r="/blog"){let n=`https://${t.domain.replace(/^https?:\/\//,"").replace(/\/+$/,"")}${R(r,e.slug)}`,i=`${e.name} - ${t.name}`,o=e.bio??`Read articles by ${e.name} on ${t.name}.`;return {title:i,description:o,authors:[{name:e.name}],openGraph:{title:i,description:o,type:"profile",url:n,images:e.avatarUrl?[{url:e.avatarUrl,alt:e.name}]:void 0,siteName:t.name},twitter:{card:e.avatarUrl?"summary_large_image":"summary",title:i,description:o,images:e.avatarUrl?[e.avatarUrl]:void 0},alternates:{canonical:n}}}var Te=class{articles=new Map;operations=new Map;async saveArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if(Array.from(this.articles.values()).some(a=>a.id===t.id))return n}else return n;if(this.articles.has(t.slug)){let o={success:false,error:{code:"PUB003",message:"This URL is already in use. Please choose another."},idempotencyKey:r};return await this.storeOperationResult(r,o),o}this.articles.set(t.slug,t);let i={success:true,url:`/${t.slug}`,platformPostId:t.id,publishedAt:t.publishedAt,idempotencyKey:r};return await this.storeOperationResult(r,i),i}async getArticle(t){return this.articles.get(t)??null}async listArticles(t={}){let{limit:r=10,offset:n=0,sortBy:i="publishedAt",order:o="desc"}=t,a=Array.from(this.articles.values());return a.sort((l,c)=>{let d=new Date(l[i]).getTime(),m=new Date(c[i]).getTime();return o==="desc"?m-d:d-m}),{articles:a.slice(n,n+r),total:a.length}}async removeArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if(!this.articles.has(t))return n}else return n;if(!this.articles.has(t)){let o={success:false,error:{code:"PUB007",message:"Article not found"},idempotencyKey:r};return await this.storeOperationResult(r,o),o}this.articles.delete(t);let i={success:true,idempotencyKey:r};return await this.storeOperationResult(r,i),i}async checkIdempotency(t){return this.operations.get(t)??null}async storeOperationResult(t,r){this.operations.set(t,r);}};function yn(){let e=globalThis;if(e.__BLOG_PLATFORM_STORAGE_WARNED__)return;e.__BLOG_PLATFORM_STORAGE_WARNED__=true;let t="Blog platform: No storage provider configured. Falling back to in-memory storage (data is not persisted).";process.env.NODE_ENV==="production"?console.error(`${t} Call initBlogPlatform({ storage: /* your persistent adapter */ }) to avoid data loss.`):console.warn(t);}function vn(){let e=globalThis;e.__BLOG_PLATFORM_STORAGE__||(yn(),e.__BLOG_PLATFORM_STORAGE__=new Te);let t=e.__BLOG_PLATFORM_STORAGE__;if(!t)throw new Error("Blog platform storage not initialized");return t}function H(){return vn()}function Ze(e){let t=globalThis;t.__BLOG_PLATFORM_STORAGE__=e;}function et(e){let t=new Map;for(let r of e)r.author?.slug&&t.set(r.author.slug,Et(t.get(r.author.slug),r.author));return Array.from(t.values()).sort((r,n)=>r.name.localeCompare(n.name))}function _t(e,t){let r=t.filter(i=>i.author?.slug===e).sort((i,o)=>new Date(o.publishedAt).getTime()-new Date(i.publishedAt).getTime()),n=r.reduce((i,o)=>o.author?Et(i,o.author):i,null);return n?{author:n,articles:r}:null}async function Pn(e,t={},r=H()){let{articles:n}=await r.listArticles({limit:t.limit??1e3,offset:t.offset??0,sortBy:"publishedAt",order:"desc"});return _t(e,n)}function Et(e,t){return e?{...e,bio:e.bio??t.bio,avatarUrl:e.avatarUrl??t.avatarUrl,pronouns:e.pronouns??t.pronouns,socialLinks:e.socialLinks??t.socialLinks,toneAdjectives:e.toneAdjectives.length>0?e.toneAdjectives:t.toneAdjectives}:t}function An(e){let t=e.topics??[];return t.find(r=>r.isPrimary)??t[0]??null}function tt(e){let t=new Map;for(let r of e)for(let n of r.topics??[])t.has(n.slug)||t.set(n.slug,n);return Array.from(t.values()).sort((r,n)=>r.name.localeCompare(n.name))}function rt(e,t){let r=e.filter(i=>(i.topics??[]).some(o=>o.slug===t));if(r.length===0)return null;let n=r.flatMap(i=>i.topics??[]).find(i=>i.slug===t)??null;return n?{topic:n,articles:r}:null}function Nn({articles:e,basePath:t="/blog",title:r="Topics",description:n="Browse articles by topic.",className:i,theme:o}){let a=T(t)||"/",s=tt(e);return jsxRuntime.jsxs("main",{style:_(o),className:f("blog-topics-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",i),children:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(F__default.default,{href:a,className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all articles"}),jsxRuntime.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-balance sm:text-5xl",children:r}),jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),s.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No topics have published articles yet."}):jsxRuntime.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:s.map(l=>{let c=e.filter(d=>(d.topics??[]).some(m=>m.slug===l.slug)).length;return jsxRuntime.jsxs(F__default.default,{href:C(a,`topics/${l.slug}`),className:"group rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] p-5 transition hover:border-[var(--blog-accent)] hover:no-underline",children:[jsxRuntime.jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold transition-colors",children:l.name}),l.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:l.description}),jsxRuntime.jsxs("p",{className:"text-muted-foreground mt-4 text-sm",children:[c," ",c===1?"article":"articles"]})]},l.slug)})})]})}function Rn({articles:e,topicSlug:t,basePath:r="/blog",className:n,theme:i}){let o=T(r)||"/",a=rt(e,t);return jsxRuntime.jsxs("main",{style:_(i),className:f("blog-topic-archive-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",n),children:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(F__default.default,{href:C(o,"topics"),className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all topics"}),jsxRuntime.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-balance sm:text-5xl",children:a?.topic.name??"Topic not found"}),a?.topic.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:a.topic.description})]}),a?jsxRuntime.jsx("div",{className:"grid gap-5 md:grid-cols-2",children:a.articles.map(s=>jsxRuntime.jsx(Tn,{article:s,topic:a.topic,basePath:o},s.id))}):jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No published articles were found for this topic."})]})}function Tn({article:e,topic:t,basePath:r}){let n=C(r,e.slug),i=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxRuntime.jsxs(F__default.default,{href:n,className:"group overflow-hidden rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] transition hover:border-[var(--blog-accent)] hover:no-underline",children:[e.featuredImage&&jsxRuntime.jsx("div",{className:"relative aspect-[16/9] overflow-hidden",children:jsxRuntime.jsx(qe__default.default,{src:e.featuredImage,alt:e.featuredImageAlt??e.title,width:640,height:360,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})}),jsxRuntime.jsxs("div",{className:"space-y-3 p-5",children:[jsxRuntime.jsx("span",{className:"inline-flex rounded-full border border-[var(--blog-accent-border)] px-2.5 py-1 text-xs font-medium text-[var(--blog-text-accent)]",children:t.name}),jsxRuntime.jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold text-balance transition-colors",children:e.title}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:e.excerpt}),jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm",children:i})]})]})}function Ln({articles:e,basePath:t="/blog",title:r="Authors",description:n="Browse articles by author.",className:i,theme:o}){let a=T(t)||"/",s=et(e);return jsxRuntime.jsxs("main",{style:_(o),className:f("blog-authors-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",i),children:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(F__default.default,{href:a,className:"text-muted-foreground text-sm font-medium transition-colors hover:text-[var(--blog-accent)]",children:"Back to all articles"}),jsxRuntime.jsx("h1",{className:"text-4xl font-semibold tracking-tight text-balance sm:text-5xl",children:r}),jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),s.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No authors have published articles yet."}):jsxRuntime.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:s.map(l=>{let c=e.filter(d=>d.author?.slug===l.slug).length;return jsxRuntime.jsx(F__default.default,{href:R(a,l.slug),className:"group rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] p-5 transition hover:border-[var(--blog-accent)] hover:no-underline",children:jsxRuntime.jsxs("div",{className:"flex items-start gap-4",children:[jsxRuntime.jsx(kn,{author:l}),jsxRuntime.jsxs("div",{className:"min-w-0 space-y-2",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold transition-colors group-hover:text-[var(--blog-accent)]",children:l.name}),l.bio&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:l.bio}),jsxRuntime.jsxs("p",{className:"text-muted-foreground text-sm",children:[c," ",c===1?"article":"articles"]})]})]})},l.slug)})})]})}function kn({author:e}){let t=In(e.name);return e.avatarUrl?jsxRuntime.jsx(qe__default.default,{src:e.avatarUrl,alt:e.name,width:56,height:56,className:"size-14 shrink-0 rounded-full border border-[var(--blog-accent-border)] object-cover"}):jsxRuntime.jsx("span",{className:"bg-muted text-muted-foreground inline-flex size-14 shrink-0 items-center justify-center rounded-full text-base font-semibold",children:t})}function In(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function nt(e){let t=e.headers.get("Authorization");if(!t)return null;let n=/^Bearer\s+(.+)$/i.exec(t);if(n?.[1])return n[1];let o=/^Token\s+(.+)$/i.exec(t);return o?.[1]?o[1]:null}var Le=class{validApiKeys;constructor(t){this.validApiKeys=new Set(t);}async validateToken(t){return t?.trim()?this.validApiKeys.has(t)?{valid:true,context:{tokenHash:this.hashToken(t)}}:{valid:false,errorCode:"invalid"}:{valid:false,errorCode:"missing"}}extractToken=t=>nt(t);hashToken(t){return t.substring(0,8)+"..."}},ne=class extends Le{constructor(t="BLOG_PLATFORM_API_KEYS"){let r=process.env[t];!r&&t==="BLOG_PLATFORM_API_KEYS"&&(r=process.env.BLOG_AUTH_TOKEN);let n=r?r.split(",").map(i=>i.trim()).filter(Boolean):[];n.length===0&&console.warn(`\u26A0\uFE0F No API keys found in environment variable ${t}${t==="BLOG_PLATFORM_API_KEYS"?" (set BLOG_PLATFORM_API_KEYS or BLOG_AUTH_TOKEN)":""}. Authentication will fail for all requests.`),super(n);}},be=class{async validateToken(){return {valid:true,context:{development:true}}}extractToken(){return "development-mode"}},ke=class{hasWarned=false;async validateToken(t){return this.hasWarned||(console.error("\u274C SECURITY WARNING: Blog platform authentication not initialized! All requests will be rejected. Call initBlogPlatform() to configure authentication."),this.hasWarned=true),{valid:false,errorCode:"invalid"}}};function Bn(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??=new ke,globalThis.__BLOG_PLATFORM_AUTH_CONFIG__}function Ie(e){globalThis.__BLOG_PLATFORM_AUTH_CONFIG__=e;}function ot(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??Bn()}function On(e){Ie(new ne(e));}async function G(e){let t=ot(),r=t.extractToken?t.extractToken(e):nt(e);if(!r)return {authenticated:false,result:{valid:false,errorCode:"missing"},token:null};let n=await t.validateToken(r);return {authenticated:n.valid,result:n,token:r}}function _n(e,t=""){let n=ot().errorMessages??{},i,o;switch(e.errorCode){case "missing":i=n.missing??"Authentication token is required",o="PUB005";break;case "expired":i=n.expired??"Authentication token has expired",o="PUB005";break;default:i=n.invalid??"Invalid authentication credentials",o="PUB005";break}return {success:false,error:{code:o,message:i,details:{authError:e.errorCode??"invalid"}},idempotencyKey:t}}async function X(e){let t=await G(e);return t.authenticated?{authenticated:true,context:t.result.context}:{authenticated:false,error:_n(t.result)}}function En(){let e=process.env.SKIP_BLOG_PLATFORM_AUTH;return e==="true"||e==="1"||process.env.NODE_ENV==="test"}function $n(){return globalThis.__BLOG_PLATFORM_RATE_LIMITER__??null}function Dn(e){let t=globalThis;t.__BLOG_PLATFORM_RATE_LIMITER__=e;}function Be(e){let{redisUrl:t,redisToken:r,requestsPerMinute:n=5,keyPrefix:i="blog-platform-ratelimit",analytics:o=true}=e,a=new redis.Redis({url:t,token:r}),s=new ratelimit.Ratelimit({redis:a,analytics:o,prefix:i,limiter:ratelimit.Ratelimit.slidingWindow(n,"1m")});Dn(s);}function it(){let e=process.env.UPSTASH_REDIS_REST_URL,t=process.env.UPSTASH_REDIS_REST_TOKEN;if(!e||!t){console.warn("Blog platform: No Upstash Redis configuration found. Rate limiting disabled.");return}Be({redisUrl:e,redisToken:t}),console.log("Blog platform: Rate limiting configured (5 requests per minute per token)");}async function Dt(e){let t=$n();if(!t)return console.warn("Blog platform: Rate limiter not configured. All requests allowed."),{success:true,remaining:999,reset:Date.now()+6e4,limit:5,count:0};try{let r=await t.limit(e);return {success:r.success,remaining:r.remaining,reset:r.reset,limit:r.limit,count:r.limit-r.remaining}}catch(r){return console.error("Blog platform: Rate limit check failed:",r),{success:true,remaining:0,reset:Date.now()+6e4,limit:5,count:0}}}function Ut(e,t=""){let r=Math.ceil((e.reset-Date.now())/6e4);return {success:false,error:{code:"PUB011",message:`Rate limit exceeded. You can make ${e.limit} requests per minute. Try again in ${r} minute(s).`,details:{rateLimit:e}},idempotencyKey:t}}async function V(e,t=""){let r=await Dt(e);return r.success?{allowed:true,rateLimitResult:r}:{allowed:false,errorResponse:Ut(r,t)}}function B(e){return {"X-RateLimit-Limit":e.limit.toString(),"X-RateLimit-Remaining":e.remaining.toString(),"X-RateLimit-Reset":e.reset.toString(),"Retry-After":Math.ceil((e.reset-Date.now())/1e3).toString()}}function Oe(e){let{auth:t,storage:r,rateLimit:n,autoRateLimit:i=true}=e;if(!t)throw new Error(`Blog platform initialization failed: 'auth' is required.
|
|
78
78
|
Example: initBlogPlatform({ auth: new EnvAuth() })
|
|
79
|
-
See https://github.com/xexr/blog-platform#authentication for more details.`);console.log("Blog platform: Setting up authentication"),
|
|
79
|
+
See https://github.com/xexr/blog-platform#authentication for more details.`);console.log("Blog platform: Setting up authentication"),Ie(t),n?(console.log("Blog platform: Using custom rate limiting configuration"),Be(n)):i?(console.log("Blog platform: Auto-configuring rate limiting from environment"),it()):console.log("Blog platform: Rate limiting disabled"),r?(console.log("Blog platform: Using custom storage provider"),Ze(r)):console.log("Blog platform: Using default in-memory storage (not suitable for production)"),console.log("Blog platform initialized successfully"),globalThis.__BLOG_PLATFORM_INITIALISED__=true;}function Un(e){if(globalThis.__BLOG_PLATFORM_INITIALISED__){console.log("Blog platform: Already initialized, skipping");return}console.log("Blog platform: Initializing blog platform once"),Oe(e);}function Hn(){Oe({auth:new be,autoRateLimit:false}),console.log("Blog platform: Development mode enabled (no auth, in-memory storage, no rate limiting)");}function jn(e){let t=e??"BLOG_PLATFORM_API_KEYS";if(!process.env[t])throw new Error(`Missing required environment variable: ${t}. Set this to a comma-separated list of API keys for blog platform authentication.`);Oe({auth:new ne(t),autoRateLimit:true}),console.log("Blog platform: Production mode enabled (environment-based auth, rate limiting)");}var w=sqliteCore.sqliteTable("bp_articles",{id:sqliteCore.text("id").primaryKey(),slug:sqliteCore.text("slug").notNull(),title:sqliteCore.text("title").notNull(),excerpt:sqliteCore.text("excerpt").notNull(),content:sqliteCore.text("content").notNull(),readingSeconds:sqliteCore.integer("reading_seconds").notNull(),wordCount:sqliteCore.integer("word_count").notNull(),publishedAt:sqliteCore.text("published_at").notNull(),updatedAt:sqliteCore.text("updated_at").notNull(),featuredImage:sqliteCore.text("featured_image"),featuredImageAlt:sqliteCore.text("featured_image_alt"),authorJson:sqliteCore.text("author_json"),siteJson:sqliteCore.text("site_json").notNull(),metaJson:sqliteCore.text("meta_json").notNull(),version:sqliteCore.integer("version").notNull()},e=>({slugUniqueIdx:sqliteCore.uniqueIndex("bp_articles_slug_unique").on(e.slug)})),oe=sqliteCore.sqliteTable("bp_operations",{key:sqliteCore.text("key").primaryKey(),resultJson:sqliteCore.text("result_json").notNull(),createdAt:sqliteCore.integer("created_at",{mode:"timestamp_ms"}).notNull(),expiresAt:sqliteCore.integer("expires_at",{mode:"timestamp_ms"})});function qn(e){return {id:e.id,slug:e.slug,title:e.title,excerpt:e.excerpt,content:e.content,readingSeconds:e.readingSeconds,wordCount:e.wordCount,publishedAt:e.publishedAt,updatedAt:e.updatedAt,featuredImage:e.featuredImage??null,featuredImageAlt:e.featuredImageAlt??null,authorJson:e.author?JSON.stringify(e.author):null,siteJson:JSON.stringify(e.site),metaJson:JSON.stringify({...e.meta,__bloggyTopics:e.topics??[]}),version:e.version}}function Ht(e){return {id:e.id,slug:e.slug,title:e.title,excerpt:e.excerpt,content:e.content,readingSeconds:e.readingSeconds,wordCount:e.wordCount,publishedAt:e.publishedAt,updatedAt:e.updatedAt,featuredImage:e.featuredImage??void 0,featuredImageAlt:e.featuredImageAlt??void 0,author:e.authorJson?JSON.parse(e.authorJson):null,site:JSON.parse(e.siteJson),topics:Xn(e.metaJson),meta:Wn(e.metaJson),version:e.version}}function Xn(e){return JSON.parse(e).__bloggyTopics??[]}function Wn(e){let t=JSON.parse(e);return delete t.__bloggyTopics,t}var at=class{db;options;constructor(t,r={}){this.db=t,this.options=r;}async saveArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if((await this.db.select({id:w.id}).from(w).where(drizzleOrm.eq(w.id,t.id)).limit(1)).length!==0)return n}else return n;let i=await this.db.select().from(w).where(drizzleOrm.eq(w.slug,t.slug)).limit(1),o=i[0];if(o&&o.id!==t.id){let l={success:false,error:{code:"PUB003",message:"This URL is already in use. Please choose another."},idempotencyKey:r};return await this.storeOperationResult(r,l),l}let a=qn(t);i.length===0?await this.db.insert(w).values(a).run():await this.db.update(w).set({title:a.title,excerpt:a.excerpt,content:a.content,readingSeconds:a.readingSeconds,wordCount:a.wordCount,updatedAt:a.updatedAt,featuredImage:a.featuredImage,featuredImageAlt:a.featuredImageAlt,authorJson:a.authorJson,siteJson:a.siteJson,metaJson:a.metaJson,version:a.version}).where(drizzleOrm.and(drizzleOrm.eq(w.id,a.id),drizzleOrm.eq(w.slug,a.slug))).run();let s={success:true,url:`/${t.slug}`,platformPostId:t.id,publishedAt:t.publishedAt,idempotencyKey:r};return await this.storeOperationResult(r,s),s}async getArticle(t){let r=await this.db.select().from(w).where(drizzleOrm.eq(w.slug,t)).limit(1);return r[0]?Ht(r[0]):null}async listArticles(t={}){let{limit:r=10,offset:n=0,sortBy:i="publishedAt",order:o="desc"}=t,a=i==="publishedAt"?w.publishedAt:w.updatedAt,s=o==="desc"?drizzleOrm.desc(a):a,l=await this.db.select().from(w).orderBy(s).limit(r).offset(n),c=await this.db.select({c:drizzleOrm.sql`count(*)`}).from(w),d=Number(c?.[0]?.c??0);return {articles:l.map(Ht),total:d}}async removeArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if(!((await this.db.select({id:w.id}).from(w).where(drizzleOrm.eq(w.slug,t)).limit(1)).length>0))return n}else return n;if(!(await this.db.select().from(w).where(drizzleOrm.eq(w.slug,t)).limit(1))[0]){let a={success:false,error:{code:"PUB007",message:"Article not found"},idempotencyKey:r};return await this.storeOperationResult(r,a),a}await this.db.delete(w).where(drizzleOrm.eq(w.slug,t)).run();let o={success:true,idempotencyKey:r};return await this.storeOperationResult(r,o),o}async checkIdempotency(t){let r=await this.db.select().from(oe).where(drizzleOrm.eq(oe.key,t)).limit(1);if(!r[0])return null;try{return JSON.parse(r[0].resultJson)}catch{return null}}async storeOperationResult(t,r){let n=Date.now(),i=this.options.operationTtlMs?n+this.options.operationTtlMs:null;await this.db.delete(oe).where(drizzleOrm.eq(oe.key,t)).run(),await this.db.insert(oe).values({key:t,resultJson:JSON.stringify(r),createdAt:new Date(n),expiresAt:i?new Date(i):null}).run();}};function Kn(){return {createArticles:`CREATE TABLE IF NOT EXISTS bp_articles (
|
|
80
80
|
id TEXT PRIMARY KEY,
|
|
81
81
|
slug TEXT NOT NULL UNIQUE,
|
|
82
82
|
title TEXT NOT NULL,
|
|
@@ -97,11 +97,11 @@ See https://github.com/xexr/blog-platform#authentication for more details.`);con
|
|
|
97
97
|
result_json TEXT NOT NULL,
|
|
98
98
|
created_at INTEGER NOT NULL,
|
|
99
99
|
expires_at INTEGER
|
|
100
|
-
);`}}function
|
|
101
|
-
`)}function
|
|
100
|
+
);`}}function ie(e,t=true){let r=e.trim();return r=r.replace(/\/+$/,""),/^https?:\/\//.exec(r)||(r=`${t?"https":"http"}://${r}`),t&&r.startsWith("http://")&&(r=r.replace("http://","https://")),r}function zt(e){let t=e.trim();if(!t)throw new Error("Slug cannot be empty");if(!/^[a-z0-9-]+$/.test(t))throw new Error("Slug can only contain lowercase letters, numbers, and hyphens");let n=t.replace(/-+/g,"-").replace(/^-+|-+$/g,"");if(!n)throw new Error("Slug cannot consist only of hyphens");return n}function Z(e,t={}){let{forceHttps:r=true,removeTrailingSlash:n=true,domain:i=e.site.domain,pathPrefix:o="/blog"}=t;if(!i)throw new Error("Domain is required for canonical URL generation");if(!e.slug)throw new Error("Article slug is required for canonical URL generation");let a=ie(i,r),s=zt(e.slug),l=o.replace(/^(?!\/)/,"/").replace(/\/+$/,""),c=`${a}${l}/${s}`;return n&&(c=c.replace(/\/+$/,"")),c}function Jn(e,t,r={}){return Z({slug:t,site:e},r)}function Yn(e){try{let t=new URL(e);return !(!["http:","https:"].includes(t.protocol)||!t.hostname||t.hostname.length===0||/^https?:\/\/\//.exec(e)&&!/^https?:\/\/[^\/]/.exec(e)||e.includes(" "))}catch{return false}}function Qn(e){try{let t=new URL(e);return `${t.protocol}//${t.host}`}catch{throw new Error("Invalid canonical URL provided")}}function Zn(e,t={}){let r=Z(e,t);return {...e,meta:{...e.meta,canonicalUrl:r}}}function eo(e,t={},r){let n=r?.path??"/blog",o=`https://${t.canonical?.domain??e.domain}${n}`,a=r?.title?`${r.title} | ${e.name}`:e.name,s=r?.description??e.description,l=t.openGraph?.siteName??e.name,c=[{name:"description",content:s},{name:"author",content:l}];r?.pageNumber&&r.pageNumber>1&&c.push({name:"page",content:r.pageNumber.toString()}),t.meta?.robots&&c.push({name:"robots",content:t.meta.robots}),t.meta?.viewport&&c.push({name:"viewport",content:t.meta.viewport}),t.meta?.themeColor&&c.push({name:"theme-color",content:t.meta.themeColor}),t.meta?.applicationName&&c.push({name:"application-name",content:t.meta.applicationName});let d=[{property:"og:title",content:a},{property:"og:description",content:s},{property:"og:url",content:o},{property:"og:site_name",content:l},{property:"og:locale",content:t.openGraph?.locale??e.locale},{property:"og:type",content:t.openGraph?.type??"website"}];t.openGraph?.defaultImage&&d.push({property:"og:image",content:t.openGraph.defaultImage},{property:"og:image:alt",content:`${l} - ${e.tagline}`});let m=to(null,{site:t.twitter?.site,creator:t.twitter?.creator,cardType:t.twitter?.cardType??"summary"},{title:a,description:s,image:t.openGraph?.defaultImage});return {meta:c,openGraph:d,twitter:m,links:[{rel:"canonical",href:o}],title:a,description:s,canonicalUrl:o}}function to(e,t,r){let n=r?.title??e?.meta.title??e?.title??"",i=r?.description??e?.meta.description??e?.excerpt??"",o=r?.image??e?.meta.ogImage??e?.featuredImage,a=[{name:"twitter:card",content:t.cardType},{name:"twitter:title",content:n},{name:"twitter:description",content:i}];return t.site&&a.push({name:"twitter:site",content:t.site}),t.creator&&a.push({name:"twitter:creator",content:t.creator}),o&&(a.push({name:"twitter:image",content:o}),e?.featuredImageAlt),a}function ro(e){let t=[];return t.push(`<title>${O(e.title)}</title>`),e.meta.forEach(r=>{let n=[];r.name&&n.push(`name="${O(r.name)}"`),r.property&&n.push(`property="${O(r.property)}"`),r.httpEquiv&&n.push(`http-equiv="${O(r.httpEquiv)}"`),n.push(`content="${O(r.content)}"`),t.push(`<meta ${n.join(" ")} />`);}),e.openGraph.forEach(r=>{t.push(`<meta property="${O(r.property)}" content="${O(r.content)}" />`);}),e.twitter.forEach(r=>{t.push(`<meta name="${O(r.name)}" content="${O(r.content)}" />`);}),e.links.forEach(r=>{let n=[];n.push(`rel="${O(r.rel)}"`),n.push(`href="${O(r.href)}"`),r.type&&n.push(`type="${O(r.type)}"`),r.title&&n.push(`title="${O(r.title)}"`),t.push(`<link ${n.join(" ")} />`);}),t.join(`
|
|
101
|
+
`)}function O(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function no(e){let t=[],r=[];return e.title?e.title.length>60?r.push("Title longer than 60 characters may be truncated in search results"):e.title.length<30&&r.push("Title shorter than 30 characters may not be descriptive enough"):t.push("Title is required"),e.description?e.description.length>160?r.push("Meta description longer than 160 characters may be truncated"):e.description.length<120&&r.push("Meta description shorter than 120 characters may not be descriptive enough"):t.push("Meta description is required"),e.canonicalUrl?e.canonicalUrl.startsWith("https://")||r.push("Canonical URL should use HTTPS for better SEO"):t.push("Canonical URL is required"),e.openGraph.find(o=>o.property==="og:image")||r.push("OpenGraph image missing - social media sharing will not show image preview"),e.twitter.find(o=>o.name==="twitter:card")||r.push("Twitter Card type missing - Twitter sharing may not display properly"),{valid:t.length===0,errors:t,warnings:r}}async function st(e,t,r=[],n={}){let{includeAuthorPages:i=true,includePaginationPages:o=true,articlesPerPage:a=10,maxEntries:s=5e4,changeFrequency:l={},priority:c={}}=n,d=[],m=ie(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true),x=n.canonical?.pathPrefix??"/blog";if(d.push({url:`${m}${x}`,lastModified:ae(t),changeFrequency:l.homePage??"daily",priority:c.homePage??1}),t.forEach(h=>{if(d.length>=s)return;let p=Z(h,n.canonical);d.push({url:p,lastModified:h.updatedAt,changeFrequency:l.articles??"monthly",priority:c.articles??.8});}),i&&r.forEach(h=>{if(d.length>=s)return;let p=`${m}${R(x,h.slug)}`,g=t.filter(E=>E.author?.id===h.id),A=ae(g);d.push({url:p,lastModified:A,changeFrequency:l.authorPages??"weekly",priority:c.authorPages??.6});}),o&&t.length>a){let h=Math.ceil(t.length/a);for(let p=2;p<=h&&!(d.length>=s);p++)d.push({url:`${m}${x}?page=${p}`,lastModified:ae(t),changeFrequency:l.paginationPages??"daily",priority:c.paginationPages??.5});}return d}function oo(e,t,r=[],n={}){let{includeAuthorPages:i=true,includePaginationPages:o=true,articlesPerPage:a=10,maxEntries:s=5e4,changeFrequency:l={},priority:c={}}=n,d=[],m=ie(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true),x=n.canonical?.pathPrefix??"/blog",h=new Date().toISOString(),p=1;if(p+=t.length,i&&(p+=r.length),o&&t.length>a){let A=Math.ceil(t.length/a);p+=A-1;}let g=p>s;if(d.push({loc:`${m}${x}`,lastmod:ae(t),changefreq:l.homePage??"daily",priority:c.homePage??1}),t.forEach(A=>{if(d.length>=s)return;let E=Z(A,n.canonical);d.push({loc:E,lastmod:A.updatedAt,changefreq:l.articles??"monthly",priority:c.articles??.8});}),i&&r.forEach(A=>{if(d.length>=s)return;let E=`${m}${R(x,A.slug)}`,Yt=t.filter(Zt=>Zt.author?.id===A.id),Qt=ae(Yt);d.push({loc:E,lastmod:Qt,changefreq:l.authorPages??"weekly",priority:c.authorPages??.6});}),o&&t.length>a){let A=Math.ceil(t.length/a);for(let E=2;E<=A&&!(d.length>=s);E++)d.push({loc:`${m}${x}?page=${E}`,lastmod:ae(t),changefreq:l.paginationPages??"daily",priority:c.paginationPages??.5});}return {entries:d,totalEntries:d.length,truncated:g,generatedAt:h,baseUrl:m}}function Gt(e){let t='<?xml version="1.0" encoding="UTF-8"?>',r='<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',n="</urlset>",i=e.entries.map(o=>{let a=[];return a.push(" <url>"),a.push(` <loc>${ye(o.loc)}</loc>`),o.lastmod&&a.push(` <lastmod>${ye(o.lastmod)}</lastmod>`),o.changefreq&&a.push(` <changefreq>${ye(o.changefreq)}</changefreq>`),o.priority!==void 0&&a.push(` <priority>${o.priority.toFixed(1)}</priority>`),a.push(" </url>"),a.join(`
|
|
102
102
|
`)});return [t,r,...i,n].join(`
|
|
103
|
-
`)}function
|
|
103
|
+
`)}function io(e,t){let r='<?xml version="1.0" encoding="UTF-8"?>',n='<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',i="</sitemapindex>",o=e.map(a=>{let s=[];return s.push(" <sitemap>"),s.push(` <loc>${ye(a.url)}</loc>`),a.lastmod&&s.push(` <lastmod>${ye(a.lastmod)}</lastmod>`),s.push(" </sitemap>"),s.join(`
|
|
104
104
|
`)});return [r,n,...o,i].join(`
|
|
105
|
-
`)}function On(e){let t=[],r=[];e.entries.length===0?t.push("Sitemap must contain at least one URL"):e.entries.length>5e4&&t.push("Sitemap contains more than 50,000 URLs (Google limit)"),e.truncated&&r.push("Sitemap was truncated due to size limits"),e.entries.forEach((i,o)=>{try{new URL(i.loc);}catch{t.push(`Invalid URL at entry ${o+1}: ${i.loc}`);}i.priority!==void 0&&(i.priority<0||i.priority>1)&&t.push(`Invalid priority at entry ${o+1}: must be between 0.0 and 1.0`),i.lastmod&&!En(i.lastmod)&&t.push(`Invalid lastmod date at entry ${o+1}: ${i.lastmod}`),i.loc.length>2048&&r.push(`URL at entry ${o+1} exceeds 2048 character limit`);});let n=new Map;return e.entries.forEach(i=>{let o=n.get(i.loc)??0;n.set(i.loc,o+1);}),n.forEach((i,o)=>{i>1&&t.push(`Duplicate URL found: ${o} (appears ${i} times)`);}),{valid:t.length===0,errors:t,warnings:r}}function Z(e){return e.length===0?new Date().toISOString():e.reduce((r,n)=>{let i=new Date(n.updatedAt);return i>r?i:r},new Date(e[0].updatedAt)).toISOString()}function Bn(e,t,r=[],n={}){return async function(){let s=(await Ze(e,t,r,n)).map(l=>({loc:l.url,lastmod:typeof l.lastModified=="string"?l.lastModified:l.lastModified?.toISOString(),changefreq:l.changeFrequency,priority:l.priority})),a={entries:s,totalEntries:s.length,generatedAt:new Date().toISOString(),baseUrl:Q(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true)},u=It(a);return new Response(u,{headers:{"Content-Type":"application/xml","Cache-Control":"public, max-age=3600, s-maxage=3600"}})}}function _n(e){return async function(){let r=await e.getSite(),n=await e.getArticles(),i=e.getAuthors?await e.getAuthors():[];return Ze(r,n,i,e.options)}}function de(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function En(e){try{let t=new Date(e),r=t.toISOString(),n=e.endsWith("Z")&&!e.includes(".")?e.replace("Z",".000Z"):e;return r===n&&!isNaN(t.getTime())}catch{return false}}var ee={name:"@xexr/blog-platform",version:"1.0.8"};function kt(e){let r=e.replace(/^v/,"").split(".");if(r.length<3)throw new Error(`Invalid version format: ${e}`);let n=parseInt(r[0]??"0",10),i=parseInt(r[1]??"0",10),o=parseInt(r[2]?.split("-")[0]??"0",10);if(isNaN(n)||isNaN(i)||isNaN(o))throw new Error(`Invalid version format: ${e}`);return {major:n,minor:i,patch:o}}function B(){let e=kt(ee.version);return {name:ee.name,version:ee.version,...e}}function G(e){try{let t=e.split(" "),r={};for(let n of t){let[i,o]=n.split("/");if(!i||!o)continue;let s=kt(o),a={name:i,version:o,...s};i==="bloggy"?r.bloggyVersion=a:i==="platform"&&(r.platformVersion=a);}return r}catch{return null}}function Ot(e,t){try{return e.major!==t.major?{compatible:!1,errorCode:"PUB009",errorMessage:`Major version incompatibility: ${e.name} ${e.version} is not compatible with ${t.name} ${t.version}. Please upgrade.`}:e.minor!==t.minor?{compatible:!0,errorCode:"PUB010",warning:`Minor version difference: ${e.name} ${e.version} with ${t.name} ${t.version}. Some features may not be available.`}:{compatible:!0}}catch(r){return {compatible:false,errorMessage:`Failed to check version compatibility: ${r instanceof Error?r.message:"Unknown error"}`}}}var Bt={enableCSP:true,cspDirectives:{"default-src":"'self'","script-src":"'self' 'unsafe-inline'","style-src":"'self' 'unsafe-inline'","img-src":"'self' data: https:","font-src":"'self' https:","connect-src":"'self'","media-src":"'self'","object-src":"'none'","base-uri":"'self'","form-action":"'self'","frame-ancestors":"'none'","upgrade-insecure-requests":""},enableFrameOptions:true,frameOptions:"DENY",enableContentTypeOptions:true,enableXSSProtection:true,enableReferrerPolicy:true,referrerPolicy:"strict-origin-when-cross-origin",enableHSTS:true,hstsMaxAge:31536e3,hstsIncludeSubdomains:true,enablePermissionsPolicy:true,permissionsPolicyDirectives:{camera:"()",microphone:"()",geolocation:"()",payment:"()",usb:"()",accelerometer:"()",gyroscope:"()",magnetometer:"()"}};function $n(){let e=process.env.BLOG_PLATFORM_DISABLE_CSP==="true",t=process.env.BLOG_PLATFORM_FRAME_OPTIONS,r=process.env.BLOG_PLATFORM_DISABLE_HSTS==="true";return {...Bt,enableCSP:!e,frameOptions:t??Bt.frameOptions,enableHSTS:!r}}function Dn(e){return Object.entries(e).map(([t,r])=>r?`${t} ${r}`:t).join("; ")}function Un(e){return Object.entries(e).map(([t,r])=>`${t}=${r}`).join(", ")}function Hn(e,t={}){let r={...$n(),...t},n={};if(r.enableCSP){let i={...r.cspDirectives,...t.cspDirectives??{}};n["Content-Security-Policy"]=Dn(i);}if(r.enableFrameOptions&&(n["X-Frame-Options"]=r.frameOptions),r.enableContentTypeOptions&&(n["X-Content-Type-Options"]="nosniff"),r.enableXSSProtection&&(n["X-XSS-Protection"]="1; mode=block"),r.enableReferrerPolicy&&(n["Referrer-Policy"]=r.referrerPolicy),r.enableHSTS&&Vn(e)){let i=[`max-age=${r.hstsMaxAge}`,r.hstsIncludeSubdomains?"includeSubDomains":""].filter(Boolean).join("; ");n["Strict-Transport-Security"]=i;}if(r.enablePermissionsPolicy){let i={...r.permissionsPolicyDirectives,...t.permissionsPolicyDirectives??{}};n["Permissions-Policy"]=Un(i);}return n}function Vn(e){return !!(e.url.startsWith("https://")||e.headers.get("x-forwarded-proto")==="https"||e.headers.get("cf-visitor")?.includes('"scheme":"https"'))}function Ne(e,t={}){return Hn(e,{...t,cspDirectives:{...{"default-src":"'none'","frame-ancestors":"'none'","base-uri":"'none'"},...t.cspDirectives??{}}})}var _t={allowedOrigins:["http://localhost:3000","https://localhost:3000","http://127.0.0.1:3000","https://127.0.0.1:3000"],allowWildcard:false,allowCredentials:false,maxAge:86400,securityConfig:{}};function Et(){let e=process.env.BLOG_PLATFORM_ALLOWED_ORIGINS,t=process.env.BLOG_PLATFORM_ALLOW_WILDCARD==="true",r=process.env.BLOG_PLATFORM_ALLOW_CREDENTIALS==="true";return {..._t,allowedOrigins:e?e.split(",").map(n=>n.trim()):_t.allowedOrigins,allowWildcard:t,allowCredentials:r}}function Mt(e,t){return e?t.allowWildcard?true:t.allowedOrigins.includes(e):false}function $t(e,t){let r=e.headers.get("origin"),n={};return t.allowWildcard?n["Access-Control-Allow-Origin"]="*":r&&Mt(r,t)&&(n["Access-Control-Allow-Origin"]=r),t.allowCredentials&&!t.allowWildcard&&(n["Access-Control-Allow-Credentials"]="true"),t.allowWildcard||(n.Vary="Origin"),n}function jn(e,t,r,n){return {...$t(e,t),"Access-Control-Allow-Methods":r.join(", "),"Access-Control-Allow-Headers":n.join(", "),"Access-Control-Max-Age":t.maxAge.toString()}}var Gn=["Content-Type","X-Bloggy-Version","X-Idempotency-Key","Authorization","X-Requested-With"];function y(e,t,r={}){let{status:n=200,headers:i={},corsConfig:o={}}=r,s={...Et(),...o},a=$t(e,s),u=Ne(e,s.securityConfig),l={"Content-Type":"application/json",...a,...u,...i};return server.NextResponse.json(t,{status:n,headers:l})}function me(e,t,r={}){let{allowedHeaders:n=Gn,corsConfig:i={}}=r,o={...Et(),...i},s=e.headers.get("origin");if(s&&!o.allowWildcard&&!Mt(s,o)){let l=Ne(e,o.securityConfig);return new server.NextResponse(null,{status:403,headers:{"Content-Type":"text/plain",...l}})}let a=jn(e,o,[...t,"OPTIONS"],n),u=Ne(e,o.securityConfig);return new server.NextResponse(null,{status:200,headers:{...a,...u}})}async function zn(e){try{let t=await $(e);if(!t.authenticated){let g=await V(e);return y(e,g.error,{status:401})}let r=t.token??"anonymous",n=await D(r);if(!n.allowed){let g=n.errorResponse.error?.details?.rateLimit,P=g&&typeof g=="object"&&"limit"in g&&"remaining"in g&&"reset"in g&&"count"in g&&"success"in g?g:{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},I=T(P);return y(e,n.errorResponse,{status:429,headers:I})}if(!e.headers.get("content-type")?.includes("application/json"))return y(e,{success:!1,error:{code:"PUB001",message:"Content-Type must be application/json"},idempotencyKey:""},{status:400});let o;try{o=await e.json();}catch{return y(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let s=Fn(o);if(s.length>0)return y(e,{success:!1,error:{code:"PUB001",message:"Missing required fields",details:{errors:s}},idempotencyKey:o.idempotencyKey??""},{status:400});let a=e.headers.get("X-Bloggy-Version");if(a){let g=G(a);if(g?.platformVersion){let P=B();if(g.platformVersion.major!==P.major)return y(e,{success:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:g.platformVersion.version,serverVersion:P.version}},idempotencyKey:o.idempotencyKey},{status:409})}}if(o.dryRun){let g=[];return o.article.wordCount<50&&g.push("Article has fewer than 50 words, which may affect SEO"),(!o.article.excerpt||o.article.excerpt.length<120)&&g.push("Article excerpt is shorter than recommended 120 characters"),o.article.meta.keywords.length||g.push("No SEO keywords provided"),y(e,{success:!0,warnings:g,idempotencyKey:o.idempotencyKey},{status:200})}let u={...o.article,slug:o.slug??o.article.slug,meta:{...o.article.meta,description:o.metaDescription??o.article.meta.description}};if(!tt(u.slug))return y(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:o.idempotencyKey},{status:400});let m=await j().saveArticle(u,o.idempotencyKey),p=B(),v=T(n.rateLimitResult),h={"X-Bloggy-Version":`platform/${p.version}`,"X-Idempotency-Key":o.idempotencyKey,...v};m.success&&(h.Location=m.url??`/${u.slug}`);let d=m.success?201:m.error?.code==="PUB003"?409:400;return y(e,m,{status:d,headers:h})}catch(t){return console.error("Publish endpoint error:",t),y(e,{success:false,error:{code:"PUB007",message:"Internal server error during publishing"},idempotencyKey:""},{status:500})}}function Fn(e){let t=[];if(!e||typeof e!="object")return t.push("Request body must be a valid object"),t;let r=e;if((!r.article||typeof r.article!="object")&&t.push("Missing required field: article"),(!r.idempotencyKey||typeof r.idempotencyKey!="string")&&t.push("Missing required field: idempotencyKey"),r.article&&typeof r.article=="object"){let n=r.article,i=["id","slug","title","content","publishedAt","site"];for(let o of i)n[o]||t.push(`Missing required article field: ${o}`);if(n.site&&typeof n.site=="object"){let o=n.site,s=["id","name","domain"];for(let a of s)o[a]||t.push(`Missing required site field: ${a}`);}if(n.meta&&typeof n.meta=="object"){let o=n.meta;Array.isArray(o.keywords)||t.push("Article meta.keywords must be an array");}}return t}function tt(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function Xn(e){try{let t=await $(e);if(!t.authenticated){let d=await V(e);return server.NextResponse.json(d.error,{status:401})}let r=t.token??"anonymous",n=await D(r);if(!n.allowed){let d=n.errorResponse.error?.details?.rateLimit,g=d&&typeof d=="object"&&"limit"in d&&"remaining"in d&&"reset"in d&&"count"in d&&"success"in d?d:{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},P=T(g);return y(e,n.errorResponse,{status:429,headers:P})}if(!e.headers.get("content-type")?.includes("application/json"))return y(e,{success:!1,error:{code:"PUB001",message:"Content-Type must be application/json"},idempotencyKey:""},{status:400});let o;try{o=await e.json();}catch{return y(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let s=Wn(o);if(s.length>0)return y(e,{success:!1,error:{code:"PUB001",message:"Missing required fields",details:{errors:s}},idempotencyKey:o.idempotencyKey??""},{status:400});let a=e.headers.get("X-Bloggy-Version");if(a){let d=G(a);if(d?.platformVersion){let g=B();if(d.platformVersion.major!==g.major)return y(e,{success:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:d.platformVersion.version,serverVersion:g.version}},idempotencyKey:o.idempotencyKey},{status:409})}}if(!Kn(o.slug))return y(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:o.idempotencyKey},{status:400});if(o.dryRun){let g=await j().getArticle(o.slug),P=[];return g||P.push("Article with this slug does not exist"),y(e,{success:!0,warnings:P,idempotencyKey:o.idempotencyKey},{status:200})}let l=await j().removeArticle(o.slug,o.idempotencyKey),m=B(),p=T(n.rateLimitResult),v={"X-Bloggy-Version":`platform/${m.version}`,"X-Idempotency-Key":o.idempotencyKey,...p},h=l.success?200:l.error?.code==="PUB007"?404:400;return y(e,l,{status:h,headers:v})}catch(t){return console.error("Unpublish endpoint error:",t),y(e,{success:false,error:{code:"PUB007",message:"Internal server error during unpublishing"},idempotencyKey:""},{status:500})}}function Wn(e){let t=[];if(!e||typeof e!="object")return t.push("Request body must be a valid object"),t;let r=e;return (!r.slug||typeof r.slug!="string")&&t.push("Missing required field: slug"),(!r.idempotencyKey||typeof r.idempotencyKey!="string")&&t.push("Missing required field: idempotencyKey"),r.slug&&typeof r.slug=="string"&&!r.slug.trim()&&t.push("Slug cannot be empty"),t}function Kn(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function Jn(e){try{let t=await $(e);if(!t.authenticated){let p=await V(e),v={success:!1,versions:{bloggy:{name:"unknown",version:"unknown",major:0,minor:0,patch:0},platform:{name:"unknown",version:"unknown",major:0,minor:0,patch:0}},compatibility:{compatible:!1,errorMessage:p.error?.error?.message??"Authentication required"}};return y(e,v,{status:401})}let r=t.token??"anonymous",n=await D(r);if(!n.allowed){let p=n.errorResponse.error?.details?.rateLimit,v=p&&typeof p=="object"&&"limit"in p&&"remaining"in p&&"reset"in p&&"count"in p&&"success"in p?p:{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},h=T(v),d={success:!1,versions:{bloggy:{name:"unknown",version:"unknown",major:0,minor:0,patch:0},platform:{name:"unknown",version:"unknown",major:0,minor:0,patch:0}},compatibility:{compatible:!1,errorMessage:n.errorResponse.error?.message??"Rate limit exceeded"}};return y(e,d,{status:429,headers:h})}let i=B(),o=e.headers.get("X-Bloggy-Version"),s={name:"unknown",version:"unknown",major:0,minor:0,patch:0};if(o)try{if(/^\d+\.\d+\.\d+/.test(o)){let p=o.split("."),v=parseInt(p[0]??"0",10),h=parseInt(p[1]??"0",10),d=parseInt(p[2]?.split("-")[0]??"0",10);s={name:"bloggy",version:o,major:v,minor:h,patch:d};}else {let p=G(o);p?.bloggyVersion&&(s=p.bloggyVersion);}}catch(p){console.warn("Failed to parse X-Bloggy-Version header:",p);}let a={compatible:!0};s.version!=="unknown"&&(a=Ot(s,i));let u={success:!0,versions:{bloggy:s,platform:i},compatibility:a},l=T(n.rateLimitResult),m={"X-Bloggy-Version":`platform/${i.version}`,"Cache-Control":"public, max-age=300, stale-while-revalidate=60",...l};return y(e,u,{status:200,headers:m})}catch(t){console.error("Version endpoint error:",t);let r={success:false,versions:{bloggy:{name:"unknown",version:"unknown",major:0,minor:0,patch:0},platform:{name:"unknown",version:"unknown",major:0,minor:0,patch:0}},compatibility:{compatible:false,errorMessage:"Internal server error while checking version compatibility"},error:t instanceof Error?t.message:"Unknown error"};return y(e,r,{status:500})}}async function Qn(e,{params:t}){try{let{slug:r}=await t,n=await $(e);if(!n.authenticated){let g=await V(e);return server.NextResponse.json(g.error,{status:401})}let i=n.token??"anonymous",o=await D(i);if(!o.allowed){let g=o.errorResponse.error?.details?.rateLimit||{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},P=T(g);return y(e,o.errorResponse,{status:429,headers:P})}if(!r||!tt(r))return y(e,{exists:!1,error:{code:"PUB002",message:"Invalid slug format. Must be lowercase letters, numbers, and hyphens only."}},{status:400});let s=e.headers.get("X-Bloggy-Version");if(s){let g=G(s);if(g?.platformVersion){let P=B();if(g.platformVersion.major!==P.major)return y(e,{exists:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:g.platformVersion.version,serverVersion:P.version}}},{status:409})}}let l=await j().getArticle(r)!==null,m={exists:l,...l&&{message:"Slug is already in use. Please choose another (e.g., append '-v2')."}},p=B(),v=T(o.rateLimitResult),h={"X-Bloggy-Version":`platform/${p.version}`,...v},d=e.headers.get("X-Idempotency-Key");return d&&(h["X-Idempotency-Key"]=d,console.log(`Slug check for idempotency: ${d}, exists: ${l}`)),y(e,m,{status:200,headers:h})}catch(r){return console.error("Slug existence check error:",r instanceof Error?r.message:String(r)),y(e,{exists:false,error:{code:"PUB007",message:"Internal server error during slug check"}},{status:500})}}async function Zn(e){return me(e,["GET"])}var Cs=ee.version;
|
|
106
|
-
exports.ApiKeyAuth=
|
|
105
|
+
`)}function ao(e){let t=[],r=[];e.entries.length===0?t.push("Sitemap must contain at least one URL"):e.entries.length>5e4&&t.push("Sitemap contains more than 50,000 URLs (Google limit)"),e.truncated&&r.push("Sitemap was truncated due to size limits"),e.entries.forEach((i,o)=>{try{new URL(i.loc);}catch{t.push(`Invalid URL at entry ${o+1}: ${i.loc}`);}i.priority!==void 0&&(i.priority<0||i.priority>1)&&t.push(`Invalid priority at entry ${o+1}: must be between 0.0 and 1.0`),i.lastmod&&!co(i.lastmod)&&t.push(`Invalid lastmod date at entry ${o+1}: ${i.lastmod}`),i.loc.length>2048&&r.push(`URL at entry ${o+1} exceeds 2048 character limit`);});let n=new Map;return e.entries.forEach(i=>{let o=n.get(i.loc)??0;n.set(i.loc,o+1);}),n.forEach((i,o)=>{i>1&&t.push(`Duplicate URL found: ${o} (appears ${i} times)`);}),{valid:t.length===0,errors:t,warnings:r}}function ae(e){return e.length===0?new Date().toISOString():e.reduce((r,n)=>{let i=new Date(n.updatedAt);return i>r?i:r},new Date(e[0].updatedAt)).toISOString()}function so(e,t,r=[],n={}){return async function(){let a=(await st(e,t,r,n)).map(c=>({loc:c.url,lastmod:typeof c.lastModified=="string"?c.lastModified:c.lastModified?.toISOString(),changefreq:c.changeFrequency,priority:c.priority})),s={entries:a,totalEntries:a.length,generatedAt:new Date().toISOString(),baseUrl:ie(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true)},l=Gt(s);return new Response(l,{headers:{"Content-Type":"application/xml","Cache-Control":"public, max-age=3600, s-maxage=3600"}})}}function lo(e){return async function(){let r=await e.getSite(),n=await e.getArticles(),i=e.getAuthors?await e.getAuthors():[];return st(r,n,i,e.options)}}function ye(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function co(e){try{let t=new Date(e),r=t.toISOString(),n=e.endsWith("Z")&&!e.includes(".")?e.replace("Z",".000Z"):e;return r===n&&!isNaN(t.getTime())}catch{return false}}var se={name:"@xexr/blog-platform",version:"1.0.9"};function Vt(e){let r=e.replace(/^v/,"").split(".");if(r.length<3)throw new Error(`Invalid version format: ${e}`);let n=parseInt(r[0]??"0",10),i=parseInt(r[1]??"0",10),o=parseInt(r[2]?.split("-")[0]??"0",10);if(isNaN(n)||isNaN(i)||isNaN(o))throw new Error(`Invalid version format: ${e}`);return {major:n,minor:i,patch:o}}function D(){let e=Vt(se.version);return {name:se.name,version:se.version,...e}}function W(e){try{let t=e.split(" "),r={};for(let n of t){let[i,o]=n.split("/");if(!i||!o)continue;let a=Vt(o),s={name:i,version:o,...a};i==="bloggy"?r.bloggyVersion=s:i==="platform"&&(r.platformVersion=s);}return r}catch{return null}}function Ft(e,t){try{return e.major!==t.major?{compatible:!1,errorCode:"PUB009",errorMessage:`Major version incompatibility: ${e.name} ${e.version} is not compatible with ${t.name} ${t.version}. Please upgrade.`}:e.minor!==t.minor?{compatible:!0,errorCode:"PUB010",warning:`Minor version difference: ${e.name} ${e.version} with ${t.name} ${t.version}. Some features may not be available.`}:{compatible:!0}}catch(r){return {compatible:false,errorMessage:`Failed to check version compatibility: ${r instanceof Error?r.message:"Unknown error"}`}}}var qt={enableCSP:true,cspDirectives:{"default-src":"'self'","script-src":"'self' 'unsafe-inline'","style-src":"'self' 'unsafe-inline'","img-src":"'self' data: https:","font-src":"'self' https:","connect-src":"'self'","media-src":"'self'","object-src":"'none'","base-uri":"'self'","form-action":"'self'","frame-ancestors":"'none'","upgrade-insecure-requests":""},enableFrameOptions:true,frameOptions:"DENY",enableContentTypeOptions:true,enableXSSProtection:true,enableReferrerPolicy:true,referrerPolicy:"strict-origin-when-cross-origin",enableHSTS:true,hstsMaxAge:31536e3,hstsIncludeSubdomains:true,enablePermissionsPolicy:true,permissionsPolicyDirectives:{camera:"()",microphone:"()",geolocation:"()",payment:"()",usb:"()",accelerometer:"()",gyroscope:"()",magnetometer:"()"}};function mo(){let e=process.env.BLOG_PLATFORM_DISABLE_CSP==="true",t=process.env.BLOG_PLATFORM_FRAME_OPTIONS,r=process.env.BLOG_PLATFORM_DISABLE_HSTS==="true";return {...qt,enableCSP:!e,frameOptions:t??qt.frameOptions,enableHSTS:!r}}function po(e){return Object.entries(e).map(([t,r])=>r?`${t} ${r}`:t).join("; ")}function go(e){return Object.entries(e).map(([t,r])=>`${t}=${r}`).join(", ")}function fo(e,t={}){let r={...mo(),...t},n={};if(r.enableCSP){let i={...r.cspDirectives,...t.cspDirectives??{}};n["Content-Security-Policy"]=po(i);}if(r.enableFrameOptions&&(n["X-Frame-Options"]=r.frameOptions),r.enableContentTypeOptions&&(n["X-Content-Type-Options"]="nosniff"),r.enableXSSProtection&&(n["X-XSS-Protection"]="1; mode=block"),r.enableReferrerPolicy&&(n["Referrer-Policy"]=r.referrerPolicy),r.enableHSTS&&ho(e)){let i=[`max-age=${r.hstsMaxAge}`,r.hstsIncludeSubdomains?"includeSubDomains":""].filter(Boolean).join("; ");n["Strict-Transport-Security"]=i;}if(r.enablePermissionsPolicy){let i={...r.permissionsPolicyDirectives,...t.permissionsPolicyDirectives??{}};n["Permissions-Policy"]=go(i);}return n}function ho(e){return !!(e.url.startsWith("https://")||e.headers.get("x-forwarded-proto")==="https"||e.headers.get("cf-visitor")?.includes('"scheme":"https"'))}function _e(e,t={}){return fo(e,{...t,cspDirectives:{...{"default-src":"'none'","frame-ancestors":"'none'","base-uri":"'none'"},...t.cspDirectives??{}}})}var Xt={allowedOrigins:["http://localhost:3000","https://localhost:3000","http://127.0.0.1:3000","https://127.0.0.1:3000"],allowWildcard:false,allowCredentials:false,maxAge:86400,securityConfig:{}};function Wt(){let e=process.env.BLOG_PLATFORM_ALLOWED_ORIGINS,t=process.env.BLOG_PLATFORM_ALLOW_WILDCARD==="true",r=process.env.BLOG_PLATFORM_ALLOW_CREDENTIALS==="true";return {...Xt,allowedOrigins:e?e.split(",").map(n=>n.trim()):Xt.allowedOrigins,allowWildcard:t,allowCredentials:r}}function Kt(e,t){return e?t.allowWildcard?true:t.allowedOrigins.includes(e):false}function Jt(e,t){let r=e.headers.get("origin"),n={};return t.allowWildcard?n["Access-Control-Allow-Origin"]="*":r&&Kt(r,t)&&(n["Access-Control-Allow-Origin"]=r),t.allowCredentials&&!t.allowWildcard&&(n["Access-Control-Allow-Credentials"]="true"),t.allowWildcard||(n.Vary="Origin"),n}function bo(e,t,r,n){return {...Jt(e,t),"Access-Control-Allow-Methods":r.join(", "),"Access-Control-Allow-Headers":n.join(", "),"Access-Control-Max-Age":t.maxAge.toString()}}var xo=["Content-Type","X-Bloggy-Version","X-Idempotency-Key","Authorization","X-Requested-With"];function v(e,t,r={}){let{status:n=200,headers:i={},corsConfig:o={}}=r,a={...Wt(),...o},s=Jt(e,a),l=_e(e,a.securityConfig),c={"Content-Type":"application/json",...s,...l,...i};return server.NextResponse.json(t,{status:n,headers:c})}function ve(e,t,r={}){let{allowedHeaders:n=xo,corsConfig:i={}}=r,o={...Wt(),...i},a=e.headers.get("origin");if(a&&!o.allowWildcard&&!Kt(a,o)){let c=_e(e,o.securityConfig);return new server.NextResponse(null,{status:403,headers:{"Content-Type":"text/plain",...c}})}let s=bo(e,o,[...t,"OPTIONS"],n),l=_e(e,o.securityConfig);return new server.NextResponse(null,{status:200,headers:{...s,...l}})}async function yo(e){try{let t=await G(e);if(!t.authenticated){let g=await X(e);return v(e,g.error,{status:401})}let r=t.token??"anonymous",n=await V(r);if(!n.allowed){let g=n.errorResponse.error?.details?.rateLimit,A=g&&typeof g=="object"&&"limit"in g&&"remaining"in g&&"reset"in g&&"count"in g&&"success"in g?g:{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},E=B(A);return v(e,n.errorResponse,{status:429,headers:E})}if(!e.headers.get("content-type")?.includes("application/json"))return v(e,{success:!1,error:{code:"PUB001",message:"Content-Type must be application/json"},idempotencyKey:""},{status:400});let o;try{o=await e.json();}catch{return v(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let a=vo(o);if(a.length>0)return v(e,{success:!1,error:{code:"PUB001",message:"Missing required fields",details:{errors:a}},idempotencyKey:o.idempotencyKey??""},{status:400});let s=e.headers.get("X-Bloggy-Version");if(s){let g=W(s);if(g?.platformVersion){let A=D();if(g.platformVersion.major!==A.major)return v(e,{success:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:g.platformVersion.version,serverVersion:A.version}},idempotencyKey:o.idempotencyKey},{status:409})}}if(o.dryRun){let g=[];return o.article.wordCount<50&&g.push("Article has fewer than 50 words, which may affect SEO"),(!o.article.excerpt||o.article.excerpt.length<120)&&g.push("Article excerpt is shorter than recommended 120 characters"),o.article.meta.keywords.length||g.push("No SEO keywords provided"),v(e,{success:!0,warnings:g,idempotencyKey:o.idempotencyKey},{status:200})}let l={...o.article,slug:o.slug??o.article.slug,meta:{...o.article.meta,description:o.metaDescription??o.article.meta.description}};if(!ct(l.slug))return v(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:o.idempotencyKey},{status:400});let d=await H().saveArticle(l,o.idempotencyKey),m=D(),x=B(n.rateLimitResult),h={"X-Bloggy-Version":`platform/${m.version}`,"X-Idempotency-Key":o.idempotencyKey,...x};d.success&&(h.Location=d.url??`/${l.slug}`);let p=d.success?201:d.error?.code==="PUB003"?409:400;return v(e,d,{status:p,headers:h})}catch(t){return console.error("Publish endpoint error:",t),v(e,{success:false,error:{code:"PUB007",message:"Internal server error during publishing"},idempotencyKey:""},{status:500})}}function vo(e){let t=[];if(!e||typeof e!="object")return t.push("Request body must be a valid object"),t;let r=e;if((!r.article||typeof r.article!="object")&&t.push("Missing required field: article"),(!r.idempotencyKey||typeof r.idempotencyKey!="string")&&t.push("Missing required field: idempotencyKey"),r.article&&typeof r.article=="object"){let n=r.article,i=["id","slug","title","content","publishedAt","site"];for(let o of i)n[o]||t.push(`Missing required article field: ${o}`);if(n.site&&typeof n.site=="object"){let o=n.site,a=["id","name","domain"];for(let s of a)o[s]||t.push(`Missing required site field: ${s}`);}if(n.meta&&typeof n.meta=="object"){let o=n.meta;Array.isArray(o.keywords)||t.push("Article meta.keywords must be an array");}}return t}function ct(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function Ao(e){try{let t=await G(e);if(!t.authenticated){let p=await X(e);return server.NextResponse.json(p.error,{status:401})}let r=t.token??"anonymous",n=await V(r);if(!n.allowed){let p=n.errorResponse.error?.details?.rateLimit,g=p&&typeof p=="object"&&"limit"in p&&"remaining"in p&&"reset"in p&&"count"in p&&"success"in p?p:{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},A=B(g);return v(e,n.errorResponse,{status:429,headers:A})}if(!e.headers.get("content-type")?.includes("application/json"))return v(e,{success:!1,error:{code:"PUB001",message:"Content-Type must be application/json"},idempotencyKey:""},{status:400});let o;try{o=await e.json();}catch{return v(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let a=wo(o);if(a.length>0)return v(e,{success:!1,error:{code:"PUB001",message:"Missing required fields",details:{errors:a}},idempotencyKey:o.idempotencyKey??""},{status:400});let s=e.headers.get("X-Bloggy-Version");if(s){let p=W(s);if(p?.platformVersion){let g=D();if(p.platformVersion.major!==g.major)return v(e,{success:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:p.platformVersion.version,serverVersion:g.version}},idempotencyKey:o.idempotencyKey},{status:409})}}if(!So(o.slug))return v(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:o.idempotencyKey},{status:400});if(o.dryRun){let g=await H().getArticle(o.slug),A=[];return g||A.push("Article with this slug does not exist"),v(e,{success:!0,warnings:A,idempotencyKey:o.idempotencyKey},{status:200})}let c=await H().removeArticle(o.slug,o.idempotencyKey),d=D(),m=B(n.rateLimitResult),x={"X-Bloggy-Version":`platform/${d.version}`,"X-Idempotency-Key":o.idempotencyKey,...m},h=c.success?200:c.error?.code==="PUB007"?404:400;return v(e,c,{status:h,headers:x})}catch(t){return console.error("Unpublish endpoint error:",t),v(e,{success:false,error:{code:"PUB007",message:"Internal server error during unpublishing"},idempotencyKey:""},{status:500})}}function wo(e){let t=[];if(!e||typeof e!="object")return t.push("Request body must be a valid object"),t;let r=e;return (!r.slug||typeof r.slug!="string")&&t.push("Missing required field: slug"),(!r.idempotencyKey||typeof r.idempotencyKey!="string")&&t.push("Missing required field: idempotencyKey"),r.slug&&typeof r.slug=="string"&&!r.slug.trim()&&t.push("Slug cannot be empty"),t}function So(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function No(e){try{let t=await G(e);if(!t.authenticated){let m=await X(e),x={success:!1,versions:{bloggy:{name:"unknown",version:"unknown",major:0,minor:0,patch:0},platform:{name:"unknown",version:"unknown",major:0,minor:0,patch:0}},compatibility:{compatible:!1,errorMessage:m.error?.error?.message??"Authentication required"}};return v(e,x,{status:401})}let r=t.token??"anonymous",n=await V(r);if(!n.allowed){let m=n.errorResponse.error?.details?.rateLimit,x=m&&typeof m=="object"&&"limit"in m&&"remaining"in m&&"reset"in m&&"count"in m&&"success"in m?m:{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},h=B(x),p={success:!1,versions:{bloggy:{name:"unknown",version:"unknown",major:0,minor:0,patch:0},platform:{name:"unknown",version:"unknown",major:0,minor:0,patch:0}},compatibility:{compatible:!1,errorMessage:n.errorResponse.error?.message??"Rate limit exceeded"}};return v(e,p,{status:429,headers:h})}let i=D(),o=e.headers.get("X-Bloggy-Version"),a={name:"unknown",version:"unknown",major:0,minor:0,patch:0};if(o)try{if(/^\d+\.\d+\.\d+/.test(o)){let m=o.split("."),x=parseInt(m[0]??"0",10),h=parseInt(m[1]??"0",10),p=parseInt(m[2]?.split("-")[0]??"0",10);a={name:"bloggy",version:o,major:x,minor:h,patch:p};}else {let m=W(o);m?.bloggyVersion&&(a=m.bloggyVersion);}}catch(m){console.warn("Failed to parse X-Bloggy-Version header:",m);}let s={compatible:!0};a.version!=="unknown"&&(s=Ft(a,i));let l={success:!0,versions:{bloggy:a,platform:i},compatibility:s},c=B(n.rateLimitResult),d={"X-Bloggy-Version":`platform/${i.version}`,"Cache-Control":"public, max-age=300, stale-while-revalidate=60",...c};return v(e,l,{status:200,headers:d})}catch(t){console.error("Version endpoint error:",t);let r={success:false,versions:{bloggy:{name:"unknown",version:"unknown",major:0,minor:0,patch:0},platform:{name:"unknown",version:"unknown",major:0,minor:0,patch:0}},compatibility:{compatible:false,errorMessage:"Internal server error while checking version compatibility"},error:t instanceof Error?t.message:"Unknown error"};return v(e,r,{status:500})}}async function To(e,{params:t}){try{let{slug:r}=await t,n=await G(e);if(!n.authenticated){let g=await X(e);return server.NextResponse.json(g.error,{status:401})}let i=n.token??"anonymous",o=await V(i);if(!o.allowed){let g=o.errorResponse.error?.details?.rateLimit||{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},A=B(g);return v(e,o.errorResponse,{status:429,headers:A})}if(!r||!ct(r))return v(e,{exists:!1,error:{code:"PUB002",message:"Invalid slug format. Must be lowercase letters, numbers, and hyphens only."}},{status:400});let a=e.headers.get("X-Bloggy-Version");if(a){let g=W(a);if(g?.platformVersion){let A=D();if(g.platformVersion.major!==A.major)return v(e,{exists:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:g.platformVersion.version,serverVersion:A.version}}},{status:409})}}let c=await H().getArticle(r)!==null,d={exists:c,...c&&{message:"Slug is already in use. Please choose another (e.g., append '-v2')."}},m=D(),x=B(o.rateLimitResult),h={"X-Bloggy-Version":`platform/${m.version}`,...x},p=e.headers.get("X-Idempotency-Key");return p&&(h["X-Idempotency-Key"]=p,console.log(`Slug check for idempotency: ${p}, exists: ${c}`)),v(e,d,{status:200,headers:h})}catch(r){return console.error("Slug existence check error:",r instanceof Error?r.message:String(r)),v(e,{exists:false,error:{code:"PUB007",message:"Internal server error during slug check"}},{status:500})}}async function Co(e){return ve(e,["GET"])}var Ts=se.version;
|
|
106
|
+
exports.ApiKeyAuth=Le;exports.BlogArticlePage=kt;exports.BlogAuthorPage=Ot;exports.BlogAuthorsIndexPage=Ln;exports.BlogHomePage=yt;exports.BlogTopicArchivePage=Rn;exports.BlogTopicsIndexPage=Nn;exports.Button=or;exports.Card=me;exports.CardContent=pe;exports.CardDescription=kr;exports.CardFooter=Ir;exports.CardHeader=Cr;exports.CardTitle=Lr;exports.DrizzleStorage=at;exports.EnvAuth=ne;exports.InMemoryStorage=Te;exports.NoAuth=be;exports.PACKAGE_VERSION=Ts;exports.Pagination=ee;exports.PaginationContent=Me;exports.PaginationEllipsis=Ae;exports.PaginationItem=z;exports.PaginationLink=K;exports.PaginationNext=De;exports.PaginationPrevious=$e;exports.ShadcnPagination=Ee;exports.StructuredDataError=ce;exports.UninitializedAuth=ke;exports.autoConfigureRateLimit=it;exports.bpArticles=w;exports.bpOperations=oe;exports.buildAuthorPath=R;exports.buildBlogPath=C;exports.buttonVariants=Pe;exports.checkRateLimit=Dt;exports.cn=f;exports.configureRateLimit=Be;exports.createBlogSitemapRoute=so;exports.createDynamicBlogSitemap=lo;exports.createRateLimitErrorResponse=Ut;exports.createStructuredDataScript=J;exports.enforceRateLimit=V;exports.extractKeywordsFromArticle=gr;exports.extractTableOfContents=Fe;exports.extractTokenFromHeader=nt;exports.formatArticleDateMeta=Ve;exports.generateArticleMetadata=ln;exports.generateArticleStructuredData=we;exports.generateAuthorPageMetadata=xn;exports.generateAuthorStructuredData=Se;exports.generateBlogHomeMetadata=Sr;exports.generateBlogHomeStructuredData=Ge;exports.generateBlogSitemapEntries=st;exports.generateBreadcrumbStructuredData=dt;exports.generateCanonicalUrl=Z;exports.generateCanonicalUrlFromSlug=Jn;exports.generateCompleteArticleStructuredData=ze;exports.generateOrganizationStructuredData=He;exports.generatePaginationMetadata=mr;exports.generateSiteMetadata=eo;exports.generateSitemap=oo;exports.generateSitemapIndex=io;exports.generateWebSiteStructuredData=je;exports.getAllTopics=tt;exports.getArticlePrimaryTopic=An;exports.getAuthConfig=ot;exports.getAuthorArchive=_t;exports.getAuthorsFromArticles=et;exports.getBaseUrl=Qn;exports.getBlogThemeStyle=_;exports.getDrizzleAdapterSql=Kn;exports.getPathPrefixFromBlogUrl=pr;exports.getRateLimitHeaders=B;exports.getStorage=H;exports.getTopicArchive=rt;exports.initBlogPlatform=Oe;exports.initBlogPlatformDev=Hn;exports.initBlogPlatformOnce=Un;exports.initBlogPlatformProd=jn;exports.initEnvAuth=On;exports.isValidCanonicalUrl=Yn;exports.loadAuthorArchive=Pn;exports.metadataToHtml=ro;exports.normalizeBlogBasePath=T;exports.normalizeDomain=ie;exports.normalizeSlug=zt;exports.publishHandler=yo;exports.safeGenerateArticleStructuredData=fr;exports.setAuthConfig=Ie;exports.setStorage=Ze;exports.shouldSkipAuth=En;exports.sitemapToXml=Gt;exports.slugExistsHandler=To;exports.slugExistsOptionsHandler=Co;exports.structuredDataToJsonLd=pt;exports.unpublishHandler=Ao;exports.updateArticleCanonicalUrl=Zn;exports.usePagination=dr;exports.validateMetadata=no;exports.validateSitemap=ao;exports.validateStructuredData=mt;exports.versionHandler=No;//# sourceMappingURL=index.js.map
|
|
107
107
|
//# sourceMappingURL=index.js.map
|