@xexr/blog-platform 1.0.16 → 1.1.0
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/CHANGELOG.md +6 -0
- package/README.md +94 -5
- package/dist/app/api/blog/config/route.ts +259 -0
- package/dist/app/api/blog/publish/route.ts +1 -1
- package/dist/app/api/blog/slugs/[slug]/route.ts +1 -1
- package/dist/app/api/blog/unpublish/route.ts +1 -1
- package/dist/app/api/blog/version/route.ts +1 -1
- package/dist/app/blog/[slug]/page.mdx-security.test.ts +135 -0
- package/dist/app/blog/[slug]/page.tsx +2 -2
- package/dist/app/blog/authors/[slug]/page.tsx +2 -2
- package/dist/app/blog/page.tsx +2 -2
- package/dist/app/bloggy-indexnow-key.txt/route.ts +22 -0
- package/dist/components/AuthorByline.tsx +1 -1
- package/dist/components/AuthorPages.tsx +2 -2
- package/dist/components/TopicArchivePages.tsx +2 -2
- package/dist/index.d.mts +605 -5
- package/dist/index.d.ts +605 -5
- package/dist/index.js +18 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -10
- package/dist/index.mjs.map +1 -1
- package/dist/lib/auth.ts +1 -1
- package/dist/lib/cors.ts +2 -2
- package/dist/lib/database.ts +20 -0
- package/dist/lib/mdx.ts +46 -2
- package/dist/lib/security-headers.ts +1 -1
- package/dist/lib/storage/drizzle.ts +210 -12
- package/dist/sitemap.js +5 -5
- package/dist/sitemap.mjs +5 -5
- package/dist/types/contracts.ts +21 -0
- package/package.json +3 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Y from'next/link';import lt from'next/image';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {ChevronLeftIcon,ChevronRightIcon,MoreHorizontalIcon,ChevronsLeft,ChevronsRight,Check,ArrowUpRight,ArrowLeft,Globe,Mail,Copy,Share2}from'lucide-react';import {Slot}from'@radix-ui/react-slot';import {cva}from'class-variance-authority';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {format,formatDistanceToNow}from'date-fns';import*as Ue from'react';import Ue__default,{useState,useSyncExternalStore,useMemo,useEffect}from'react';import {MDXRemote}from'next-mdx-remote-client/rsc';import {FaXTwitter,FaLinkedinIn,FaGithub}from'react-icons/fa6';import*as dt from'@radix-ui/react-separator';import An from'remark-gfm';import wn from'remark-toc';import Sn from'rehype-slug';import {createHash}from'crypto';import {Ratelimit}from'@upstash/ratelimit';import {Redis}from'@upstash/redis';import {eq,and,desc,sql}from'drizzle-orm';import {sqliteTable,integer,text,uniqueIndex}from'drizzle-orm/sqlite-core';import {NextResponse}from'next/server';function b(...e){return twMerge(clsx(e))}var Be=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 Ar({className:e,variant:t,size:r,asChild:n=false,...o}){return jsx(n?Slot:"button",{"data-slot":"button",className:b(Be({variant:t,size:r,className:e})),...o})}function Je({className:e,...t}){return jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:b("mx-auto flex w-full justify-center",e),...t})}function Ye({className:e,...t}){return jsx("ul",{"data-slot":"pagination-content",className:b("flex flex-row items-center gap-1",e),...t})}function J({...e}){return jsx("li",{"data-slot":"pagination-item",...e})}function ie({className:e,isActive:t,size:r="icon",...n}){return jsx("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:b(Be({variant:t?"outline":"ghost",size:r}),e),...n})}function Qe({className:e,...t}){return jsxs(ie,{"aria-label":"Go to previous page",size:"default",className:b("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[jsx(ChevronLeftIcon,{}),jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function Ze({className:e,...t}){return jsxs(ie,{"aria-label":"Go to next page",size:"default",className:b("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[jsx("span",{className:"hidden sm:block",children:"Next"}),jsx(ChevronRightIcon,{})]})}function Ee({className:e,...t}){return jsxs("span",{"aria-hidden":true,"data-slot":"pagination-ellipsis",className:b("flex size-9 items-center justify-center",e),...t,children:[jsx(MoreHorizontalIcon,{className:"size-4"}),jsx("span",{className:"sr-only",children:"More pages"})]})}function ue({currentPage:e,totalPages:t,baseUrl:r,className:n,maxVisiblePages:o=5,showPrevNext:i=true,showFirstLast:a=true}){if(t<=1)return null;let c=()=>{let g=Math.floor(o/2),p=Math.max(1,e-g),x=Math.min(t,p+o-1);return x-p+1<o&&(p=Math.max(1,x-o+1)),{start:p,end:x}},{start:l,end:u}=c(),m=Array.from({length:u-l+1},(g,p)=>l+p),s=g=>g===1?r:`${r}?page=${g}`,f=e>1,h=e<t;return jsxs(Je,{className:n,children:[jsxs(Ye,{children:[a&&e>2&&jsxs(Fragment,{children:[jsx(J,{children:jsx(ie,{href:s(1),"aria-label":"Go to first page",children:jsx(ChevronsLeft,{className:"h-4 w-4"})})}),l>2&&jsx(J,{children:jsx(Ee,{})})]}),i&&jsx(J,{children:f?jsx(Qe,{href:s(e-1)}):jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pl-2.5",children:jsx("span",{className:"hidden sm:block",children:"Previous"})})}),m.map(g=>jsx(J,{children:jsx(ie,{href:s(g),isActive:g===e,children:g})},g)),i&&jsx(J,{children:h?jsx(Ze,{href:s(e+1)}):jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pr-2.5",children:jsx("span",{className:"hidden sm:block",children:"Next"})})}),a&&e<t-1&&jsxs(Fragment,{children:[u<t-1&&jsx(J,{children:jsx(Ee,{})}),jsx(J,{children:jsx(ie,{href:s(t),"aria-label":"Go to last page",children:jsx(ChevronsRight,{className:"h-4 w-4"})})})]})]}),jsxs("div",{className:"sr-only","aria-live":"polite",children:["Page ",e," of ",t]})]})}function Lr(e,t=10){let r=e.page,n=Array.isArray(r)?r[0]:r,o=Math.max(1,parseInt(n??"1",10)),i=(o-1)*t;return {currentPage:o,itemsPerPage:t,offset:i,calculateTotalPages:c=>Math.ceil(c/t)}}function kr(e,t,r,n){let o=n?`${n}${e===1?r:`${r}?page=${e}`}`:void 0,i=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:{...o&&{canonical:o}},other:{...i&&{prev:i},...a&&{next:a}}}}function B(e="/blog"){let t=e.trim();return !t||t==="/"?"":t.replace(/^(?!\/)/,"/").replace(/\/+$/,"")}function N(e,t){let r=B(e),n=t?.replace(/^\/+/,"").replace(/\/+$/,"");return n?`${r}/${n}`.replace(/\/+/g,"/"):r||"/"}function k(e,t){return N(e,`authors/${t}`)}function _r(e){let t=new URL(e);return B(t.pathname)}function Oe(e,t={}){let{customDomain:r,pathPrefix:n="/blog",language:o,isAccessibleForFree:i=true,includeOptionalProperties:a=true}=t,c=r??e.site.domain,l=r?`https://${c}${n}/${e.slug}`:e.meta.canonicalUrl??`https://${c}${n}/${e.slug}`,u=e.author?Me(e.author,{customDomain:r,pathPrefix:n}):void 0,m=tt(e.site,{customDomain:r,pathPrefix:n}),f=`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:u,publisher:m,mainEntityOfPage:{"@type":"WebPage","@id":l},wordCount:e.wordCount,timeRequired:f,isAccessibleForFree:i};return a&&(e.featuredImage&&(h.image=e.featuredImage),e.meta.keywords.length>0&&(h.keywords=[...e.meta.keywords]),(o??e.site.locale)&&(h.inLanguage=o??e.site.locale),e.site.toneAdjectives.length>0&&(h.about=e.site.toneAdjectives.map(g=>({"@type":"Thing",name:g}))),e.site.toneAdjectives.length>0&&(h.genre=[...e.site.toneAdjectives])),h}function Me(e,t={}){let{customDomain:r,pathPrefix:n="/blog"}=t,o={"@context":"https://schema.org","@type":"Person","@id":`#author-${e.id}`,name:e.name,identifier:e.id};e.bio&&(o.description=e.bio),e.avatarUrl&&(o.image=e.avatarUrl);let i=[e.socialLinks?.website,e.socialLinks?.x,e.socialLinks?.linkedin,e.socialLinks?.github].filter(a=>!!a);if(i.length>0&&(o.sameAs=i),e.slug?.trim()){let a=r?`https://${r}${k(n,e.slug)}`:k(n,e.slug);o.url=a;}return e.isGuest&&(o.additionalType="GuestAuthor"),e.toneAdjectives&&e.toneAdjectives.length>0&&(o.knowsAbout=[...e.toneAdjectives]),o}function tt(e,t={}){let{customDomain:r,pathPrefix:n="/blog"}=t,i=`https://${r??e.domain}${n}`,a={"@context":"https://schema.org","@type":"Organization","@id":`${i}#organization`,name:e.name,url:i};return e.description?.trim()&&(a.description=e.description),e.tagline?.trim()&&(a.description=a.description?`${a.description}. ${e.tagline}`:e.tagline),a}function rt(e,t={}){let{customDomain:r,pathPrefix:n="/blog",language:o,includeSearchAction:i=true}=t,c=`https://${r??e.domain}${n}`,l=tt(e,t),u={"@context":"https://schema.org","@type":"WebSite","@id":`${c}#website`,name:e.name,url:c,publisher:l};return e.description?.trim()&&(u.description=e.description),(o??e.locale)&&(u.inLanguage=o??e.locale),i&&(u.potentialAction={"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:`${c}?search={search_term_string}`},"query-input":"required name=search_term_string"}),u}function Tt(e,t={}){let{customDomain:r}=t;return {"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:e.map((n,o)=>({"@type":"ListItem",position:o+1,name:n.name,item:r&&!n.url.startsWith("http")?`https://${r}${n.url}`:n.url}))}}function nt(e,t={}){let r=[];r.push(Oe(e,t)),r.push(rt(e.site,t));let n=t.pathPrefix??"/blog",o=[{name:"Home",url:"/"},{name:e.site.name,url:n},{name:e.title,url:`${n}/${e.slug}`}];return r.push(Tt(o,t)),r}function it(e,t=[],r={}){let n=[];if(n.push(rt(e,r)),t.length>0){let o=t.slice(0,5).map(i=>Oe(i,r));n.push(...o);}return n}function Rt(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 Ct(e){return JSON.stringify(e,null,0)}function oe(e){return {type:"application/ld+json",dangerouslySetInnerHTML:{__html:Ct(e)}}}function Ir(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 Pe=class extends Error{constructor(r,n,o){super(r);this.code=n;this.details=o;this.name="StructuredDataError";}code;details};function Br(e,t={}){try{let r=Oe(e,t),n=Rt(r);return n.isValid?{schema:r}:{error:new Pe("Generated schema validation failed","VALIDATION_FAILED",n.errors)}}catch(r){return {error:new Pe("Failed to generate structured data","GENERATION_FAILED",r)}}}var G="bg-linear-to-br from-[var(--blog-accent-hover)] via-[var(--blog-text-accent)] to-fuchsia-200 bg-clip-text text-transparent",de={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 H(e={}){return {"--blog-accent":e.accentColor??de.accentColor,"--blog-accent-hover":e.accentHoverColor??de.accentHoverColor,"--blog-text-accent":e.textAccentColor??e.accentColor??de.textAccentColor,"--blog-text-accent-hover":e.textAccentHoverColor??e.accentHoverColor??de.textAccentHoverColor,"--blog-accent-bg":e.accentBackgroundColor??de.accentBackgroundColor,"--blog-accent-border":e.accentBorderColor??de.accentBorderColor}}function ot(e,t){let r=new Date(e),n=new Date(t);return {publishedDateLabel:format(r,"d MMMM yyyy"),publishedRelativeLabel:formatDistanceToNow(r,{addSuffix:true}),updatedDateLabel:format(n,"d MMMM yyyy"),isUpdated:n.getTime()!==r.getTime()}}function at(e){let t=[],r=false;for(let n of e.split(`
|
|
2
|
-
`)){if(/^\s*```/.test(n)){r=!r;continue}if(r)continue;let o=/^(#{2,3})\s+(.+?)\s*#*\s*$/.exec(n);if(!o?.[1]||!o[2])continue;let i=Or(o[2]);i&&t.push({id:Mr(i),text:i,level:o[1].length});}return t}function kt(e){return `${e} ${e===1?"section":"sections"}`}function _t(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 Mr(e){return e.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-")}var De="Thanks, you're on the list. We'll confirm before sending updates.";function Ae({siteId:e,settings:t,sourceSurface:r,sourceArticleSlug:n,sourceUrl:o,previewMode:i=false,className:a}){let[c,l]=useState(null),[u,m]=useState(null),[s,f]=useState(false),[h,g]=useState(false),p=Gr(e),x=useSyncExternalStore(Vr,()=>jr(p),()=>false),S=s||!i&&x;async function O(P){P.preventDefault(),m(null),l(null);let C=new FormData(P.currentTarget),U=st(C,"company");if(i){l(De),f(true),P.currentTarget.reset();return}g(true);try{let ce=await fetch(`${t.captureBaseUrl.replace(/\/$/,"")}/api/newsletter/subscribe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteId:Number(e),publicSubscribeToken:t.publicSubscribeToken,email:st(C,"email"),name:Fr(C,"name"),sourceSurface:r,sourceUrl:Hr(o),sourceArticleSlug:n??null,honeypot:U})});if(!ce.ok)throw new Error("Newsletter signup failed.");let Ke=await ce.json().catch(()=>null),br=qr(Ke)??De;zr(p),l(br),f(!0),P.currentTarget.reset();}catch{l(null),m("Newsletter signup failed. Please try again.");}finally{g(false);}}return jsx("section",{className:b("border-y border-[var(--blog-accent-border)] py-5 sm:py-6",a),"aria-labelledby":`newsletter-${r}-title`,children:jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.4fr)] lg:items-end",children:[jsxs("div",{className:"max-w-xl space-y-1",children:[jsx("h2",{id:`newsletter-${r}-title`,className:"text-base leading-6 font-semibold",children:t.title}),jsx("p",{className:"text-muted-foreground text-sm leading-6",children:t.description})]}),S?jsxs("div",{className:"flex items-start gap-3 text-sm leading-6 text-emerald-500",role:"status","aria-live":"polite",children:[jsx("span",{className:"mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-emerald-500/15",children:jsx(Check,{className:"size-3.5","aria-hidden":"true"})}),jsx("p",{children:c??De})]}):jsxs("form",{onSubmit:O,className:"space-y-3",children:[jsxs("div",{className:"grid gap-2 sm:grid-cols-[minmax(0,0.8fr)_minmax(0,1fr)_auto]",children:[jsx("label",{className:"sr-only",htmlFor:`newsletter-name-${r}`,children:"Name"}),jsx("input",{id:`newsletter-name-${r}`,name:"name",type:"text",autoComplete:"name",placeholder:"Name",className:"border-input bg-background text-foreground placeholder:text-muted-foreground focus-visible:ring-ring min-h-10 rounded-md border px-3 py-2 text-sm focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none"}),jsx("label",{className:"sr-only",htmlFor:`newsletter-email-${r}`,children:"Email"}),jsx("input",{id:`newsletter-email-${r}`,name:"email",type:"email",autoComplete:"email",placeholder:"Email address",required:true,className:"border-input bg-background text-foreground placeholder:text-muted-foreground focus-visible:ring-ring min-h-10 rounded-md border px-3 py-2 text-sm focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none"}),jsx("input",{type:"text",name:"company",tabIndex:-1,autoComplete:"off","aria-hidden":"true",className:"hidden"}),jsxs("button",{type:"submit",disabled:h,className:"inline-flex min-h-10 w-full shrink-0 items-center justify-center gap-2 rounded-full bg-[var(--blog-accent)] px-5 py-2 text-sm font-semibold text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60 sm:w-auto",children:[h?"Submitting...":t.buttonLabel,jsx(ArrowUpRight,{className:"size-4","aria-hidden":"true"})]})]}),u&&jsx("p",{className:"text-sm text-red-600",children:u})]})]})})}function Hr(e){return e?.startsWith("http://")||e?.startsWith("https://")?e:typeof window<"u"?window.location.href:null}function st(e,t){let r=e.get(t);return typeof r=="string"?r:""}function Fr(e,t){let r=st(e,t).trim();return r.length===0?null:r}function Gr(e){return `bloggy_newsletter_subscribed_${e}`}function jr(e){if(typeof window>"u")return false;try{if(window.localStorage.getItem(e)==="true")return !0}catch{}return typeof document>"u"?false:document.cookie.split(";").some(t=>t.trim().startsWith(`${e}=true`))}function zr(e){if(typeof window<"u")try{window.localStorage.setItem(e,"true");}catch{}typeof document<"u"&&(document.cookie=`${e}=true; Max-Age=31536000; Path=/; SameSite=Lax`);}function Vr(e){return typeof window>"u"?()=>{}:(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e))}function qr(e){return e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?e.message:null}function Ot({articles:e,siteName:t,siteTagline:r,className:n,site:o,includeStructuredData:i=false,basePath:a="/blog",pagination:c,theme:l,newsletter:u,newsletterPreviewMode:m=false}){let s=B(a)||"/",f=u??o?.newsletter,h=o?.id??e[0]?.site.id;return jsxs("div",{style:H(l),className:b("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&&jsxs("header",{className:"blog-header mb-8 text-center sm:mb-12 lg:mb-16",children:[jsx("h1",{className:b("blog-title mb-2 text-3xl font-light tracking-tight text-balance sm:text-4xl lg:text-5xl",G),children:t}),r&&jsx("p",{className:"blog-tagline text-muted-foreground text-base sm:text-lg",children:r}),jsxs("nav",{"aria-label":"Browse blog",className:"mt-5 flex flex-wrap items-center justify-center gap-2 text-sm",children:[jsx(Y,{href:s,"aria-current":"page",className:"rounded-full border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] px-3 py-1.5 font-medium text-[var(--blog-text-accent)] transition-colors hover:border-[var(--blog-text-accent)] hover:text-[var(--blog-text-accent-hover)] hover:no-underline",children:"All articles"}),jsx(Y,{href:N(s,"topics"),className:"text-muted-foreground rounded-full border border-transparent px-3 py-1.5 font-medium transition-colors hover:border-[var(--blog-accent-border)] hover:text-[var(--blog-accent)] hover:no-underline",children:"Topics"}),jsx(Y,{href:N(s,"authors"),className:"text-muted-foreground rounded-full border border-transparent px-3 py-1.5 font-medium transition-colors hover:border-[var(--blog-accent-border)] hover:text-[var(--blog-accent)] hover:no-underline",children:"Authors"})]})]}),jsxs("main",{className:"articles-list",children:[e.length===0?jsxs("div",{className:"no-articles text-muted-foreground py-16 text-center sm:py-24 lg:py-32",children:[jsx("h2",{className:"mb-3 text-xl font-light sm:mb-4 sm:text-2xl lg:text-3xl",children:"No articles yet"}),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."})]}):jsx("div",{className:"space-y-0",children:e.map(g=>jsx(Kr,{article:g,basePath:s},g.id))}),c&&c.totalPages>1&&jsx("div",{className:"pagination-wrapper mt-12",children:jsx(ue,{currentPage:c.currentPage,totalPages:c.totalPages,baseUrl:c.baseUrl??s,className:"justify-center"})})]}),f?.enabled&&h&&jsx(Ae,{siteId:h,settings:f,sourceSurface:"blog_home",previewMode:m,className:"mt-10 sm:mt-12"}),i&&o&&(()=>{let g=oe(it(o,e.slice(0,5),{pathPrefix:s}));return jsx("script",{type:g.type,dangerouslySetInnerHTML:g.dangerouslySetInnerHTML})})()]})}function Wr(e){return `${Math.ceil(e/60)} min read`}function Kr({article:e,basePath:t}){let r=N(t,e.slug),n=formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true}),o=Wr(e.readingSeconds),i=e.featuredImage;return 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:[jsxs("div",{className:"space-y-4 lg:hidden",children:[i&&jsx(Y,{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:jsx(lt,{src:i,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"})}),jsxs("div",{className:"space-y-3",children:[jsx(Y,{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: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})}),jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxs(Fragment,{children:[jsx(Bt,{author:e.author,basePath:t}),jsx("span",{className:"text-border",children:"\u2022"})]}),jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${n}`,children:n}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:o})]}),e.excerpt&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed sm:text-base",children:e.excerpt}),(e.topics??[]).length>0&&jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(a=>jsx(It,{topic:a,basePath:t},a.id))})]})]}),jsxs("div",{className:"hidden items-start gap-6 lg:flex xl:gap-8",children:[i&&jsx(Y,{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:jsx(lt,{src:i,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"})}),jsxs("div",{className:"flex min-h-[180px] flex-1 flex-col justify-between space-y-4 xl:min-h-[200px]",children:[jsxs("div",{className:"space-y-4",children:[jsx(Y,{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: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&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-base leading-relaxed xl:text-lg",children:e.excerpt}),(e.topics??[]).length>0&&jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(a=>jsx(It,{topic:a,basePath:t},a.id))})]}),jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxs(Fragment,{children:[jsx(Bt,{author:e.author,basePath:t}),jsx("span",{className:"text-border",children:"\u2022"})]}),jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${n}`,children:n}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:o})]})]})]})]})}function It({topic:e,basePath:t}){let r="rounded-full border border-[var(--blog-accent-border)] px-2.5 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)]",n=e.slug.trim();return n?jsx(Y,{href:N(t,`topics/${n}`),className:r,children:e.name}):jsx("span",{className:r,children:e.name})}function Bt({author:e,basePath:t}){return jsxs(Y,{href:k(t,e.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsx(Jr,{author:e,size:"sm"}),e.name]})}function Jr({author:e,size:t}){let r=t==="md"?"h-9 w-9 text-sm":"h-6 w-6 text-xs",n=Yr(e.name);return e.avatarUrl?jsx(lt,{src:e.avatarUrl,alt:e.name,width:t==="md"?36:24,height:t==="md"?36:24,className:b("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsx("span",{className:b("bg-muted inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function Yr(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function Qr(e,t,r,n,o="/blog"){let i=e?`${e} - Blog`:"Blog",a=n&&n.currentPage>1?`${i} - Page ${n.currentPage}`:i,c=t??"Read our latest articles and insights.",l=B(o)||"/",u=r?`${r}${n&&n.currentPage>1?`${l}?page=${n.currentPage}`:l}`:void 0,m=n&&n.currentPage>1&&r?`${r}${n.currentPage===2?l:`${l}?page=${n.currentPage-1}`}`:void 0,s=n&&n.currentPage<n.totalPages&&r?`${r}${l}?page=${n.currentPage+1}`:void 0;return {title:a,description:c,openGraph:{title:a,description:c,type:"website",...r&&{url:u}},twitter:{card:"summary_large_image",title:a,description:c},alternates:{...u&&{canonical:u}},other:{...m&&{prev:m},...s&&{next:s}}}}var en=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 we({className:e,variant:t,...r}){return jsx("div",{className:b(en({variant:t}),e),...r})}function Se({className:e,...t}){return jsx("div",{"data-slot":"card",className:b("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function rn({className:e,...t}){return jsx("div",{"data-slot":"card-header",className:b("@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 nn({className:e,...t}){return jsx("div",{"data-slot":"card-title",className:b("leading-none font-semibold",e),...t})}function on({className:e,...t}){return jsx("div",{"data-slot":"card-description",className:b("text-muted-foreground text-sm",e),...t})}function Ne({className:e,...t}){return jsx("div",{"data-slot":"card-content",className:b("px-6",e),...t})}function an({className:e,...t}){return jsx("div",{"data-slot":"card-footer",className:b("flex items-center px-6 [.border-t]:pt-6",e),...t})}function un(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 Mt(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 dn(e,t=globalThis.navigator){return t?.share?(await t.share({title:e.title,url:e.url}),"shared"):(await Mt(e.url,t?.clipboard),"copied")}function He({title:e,url:t,className:r,size:n="md"}){let[o,i]=Ue__default.useState(false),[a,c]=Ue__default.useState(false),l=Ue__default.useMemo(()=>un(t,typeof window>"u"?void 0:window.location.href),[t]);Ue__default.useEffect(()=>{if(!o)return;let h=window.setTimeout(()=>i(false),2e3);return ()=>window.clearTimeout(h)},[o]);async function u(){await Mt(l),i(true);}async function m(){c(true);try{await dn({title:e,url:l})==="copied"&&i(!0);}finally{c(false);}}let s=n==="sm"?"h-8 gap-1.5 px-2.5 text-xs":"h-9 gap-2 px-3 text-sm",f=n==="sm"?"size-3.5":"size-4";return jsxs("div",{className:b("article-top-actions flex flex-wrap items-center justify-center gap-2",r),children:[jsxs("button",{type:"button","aria-label":"Copy article link",onClick:u,className:b("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)]",s),children:[o?jsx(Check,{className:f,"aria-hidden":"true"}):jsx(Copy,{className:f,"aria-hidden":"true"}),jsx("span",{children:o?"Copied":"Copy link"})]}),jsxs("button",{type:"button","aria-label":"Share article",onClick:m,disabled:a,className:b("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",s),children:[jsx(Share2,{className:f,"aria-hidden":"true"}),jsx("span",{children:"Share"})]})]})}function Dt({alt:e="",className:t,src:r,...n}){if(typeof r!="string"||r.length===0)return jsx("img",{alt:e,className:t,...n});let o=`blog-image-preview-${pn(r)}`,i=mn(r);return jsxs(Fragment,{children:[jsx("a",{href:`#${o}`,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:jsx("img",{src:r,alt:e,className:b("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})}),jsxs("div",{id:o,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:[jsx("a",{href:"#article-content",className:"absolute inset-0 bg-black/85 backdrop-blur-sm","aria-label":"Close image preview"}),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:jsx("img",{src:i,alt:e,className:"pointer-events-auto h-[88vh] w-[94vw] rounded-3xl object-contain shadow-2xl"})}),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 mn(e){if(!e.includes("/cdn-cgi/image/"))return e;try{let t=new URL(e),r=t.pathname.split("/"),n=r.findIndex(o=>o==="image");return n===-1||r[n-1]!=="cdn-cgi"||!r[n+1]?e:(r[n+1]="width=1600,quality=90,format=webp",t.pathname=r.join("/"),t.toString())}catch{return e}}function pn(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 ut({items:e,contentId:t,variant:r,showProgress:n=true}){let o=e[0]?.id??null,i=useMemo(()=>e.map(a=>a.id),[e]);return jsxs(Fragment,{children:[jsx(bn,{contentId:t,itemIds:i}),n&&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}),jsx(yn,{items:e,activeItemId:o,variant:r})]})}function bn({contentId:e,itemIds:t}){return useEffect(()=>{let r=0,n=decodeURIComponent(window.location.hash.replace(/^#/,"")),o=l=>{let u=Array.from(document.querySelectorAll("[data-blog-toc-link]"));for(let m of u){let s=m.getAttribute("data-blog-toc-link")===l;m.setAttribute("data-active",s?"true":"false"),s?m.setAttribute("aria-current","location"):m.removeAttribute("aria-current");}},i=()=>{let l=document.getElementById(e);if(!l)return;let u=Array.from(document.querySelectorAll(`[data-blog-reading-progress="${e}"]`)),m=l.getBoundingClientRect(),s=window.scrollY,f=m.top+s,h=l.offsetHeight-window.innerHeight,g=h<=0?s>=f?100:0:(s-f)/h*100,p=xn(g);for(let P of u)P.style.transform=`scaleX(${p/100})`,P.setAttribute("aria-valuenow",String(Math.round(p)));let x=t.map(P=>document.getElementById(P)).filter(P=>!!P);if(n&&t.includes(n)){o(n),n="";return}let S=Math.max(160,Math.round(window.innerHeight*.33)),O=x.filter(P=>P.getBoundingClientRect().top<=S).at(-1)??x[0]??null;o(O?O.id:null);},a=()=>{window.cancelAnimationFrame(r),r=window.requestAnimationFrame(i);},c=()=>{n=decodeURIComponent(window.location.hash.replace(/^#/,"")),a();};return a(),window.addEventListener("scroll",a,{passive:true}),window.addEventListener("resize",a),window.addEventListener("hashchange",c),()=>{window.cancelAnimationFrame(r),window.removeEventListener("scroll",a),window.removeEventListener("resize",a),window.removeEventListener("hashchange",c);}},[e,t]),null}function xn(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function yn({items:e,activeItemId:t,variant:r}){if(e.length===0)return null;let n=jsx("ul",{className:"space-y-2 text-sm",children:e.map(o=>{let i=_t(o.id,t);return jsx("li",{className:o.level===3?"pl-4":void 0,children:jsx("a",{href:`#${o.id}`,"aria-current":i.ariaCurrent,"data-blog-toc-link":o.id,"data-active":i.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:o.text})},o.id)})});return r==="mobile"?jsxs("details",{className:"group mb-6 rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] lg:hidden",children:[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:[jsx("span",{children:"On this page"}),jsxs("span",{className:"text-muted-foreground flex items-center gap-2 text-xs font-medium",children:[kt(e.length),jsx("span",{className:"text-[var(--blog-text-accent)] transition-transform group-open:rotate-180","aria-hidden":"true",children:"\u2193"})]})]}),jsx("nav",{"aria-label":"Table of contents",className:"border-t border-[var(--blog-accent-border)] px-4 py-4",children:n})]}):jsx("aside",{className:"hidden lg:block",children: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:[jsx("p",{className:"text-muted-foreground mb-3 text-xs font-semibold tracking-wider uppercase",children:"On this page"}),n]})})}var se=Ue.forwardRef(({className:e,orientation:t="horizontal",decorative:r=true,...n},o)=>jsx(dt.Root,{ref:o,decorative:r,orientation:t,className:b("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));se.displayName=dt.Root.displayName;var Ht={mdxOptions:{remarkPlugins:[wn,An],rehypePlugins:[Nn,Sn]}};function Nn(){return e=>{Ft(e);}}function Ft(e){e.children&&(e.children=e.children.flatMap(t=>(Ft(t),Tn(t)?t.children?.filter(mt)??[t]:[t])));}function Tn(e){if(e.type!=="element"||e.tagName!=="p"||!e.children)return false;let t=e.children.filter(mt);return t.length===1&&Rn(t[0])}function Rn(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(mt);return t.length===1&&t[0]?.tagName==="img"}function mt(e){return e.type!=="text"||!!e.value?.trim()}function pt(e,t,r={}){let n=r.limit??3;if(n<=0)return [];let o=Gt(e),i=Cn(e,t),a=(m,s)=>jt(s)-jt(m)||zt(m).localeCompare(zt(s)),c=o?i.filter(m=>Gt(m)===o).sort(a):[],l=new Set(c.map(m=>m.id)),u=i.filter(m=>!l.has(m.id)).sort(a);return [...c,...u].slice(0,n)}function Cn(e,t){let r=new Set,n=new Set,o=[];for(let i of t)i.id===e.id||i.slug===e.slug||r.has(i.id)||n.has(i.slug)||(r.add(i.id),n.add(i.slug),o.push(i));return o}function Gt(e){let t=e.topics??[];return t.find(r=>r.isPrimary)?.slug??t[0]?.slug??null}function jt(e){let t=Date.parse(e.publishedAt??e.updatedAt??"");return Number.isFinite(t)?t:0}function zt(e){return e.title??e.slug}function Bn(e){return `${Math.ceil(e/60)} min read`}function En(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function On({creditText:e,creditUrl:t}){if(!e&&!t)return null;let r=e??En(t??"");return jsxs("span",{children:["Credit:"," ",t?jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 transition-colors hover:text-[var(--blog-text-accent)]",children:r}):r]})}function Jt({article:e,className:t,navigation:r,basePath:n="/blog",theme:o,postArticleCta:i,newsletter:a,newsletterPreviewMode:c=false,articles:l=[],relatedArticles:u=[],showShareLinks:m=true}){let s=B(n)||"/",f=ot(e.publishedAt,e.updatedAt),h=Bn(e.readingSeconds),g=at(e.content),p=e.meta.canonicalUrl??N(s,e.slug),x=a??e.site.newsletter,S=i??e.cta,O=e.featuredImage,P=!!(e.featuredImageCaption??e.featuredImageCreditText??e.featuredImageCreditUrl),C=u.length>0?u.slice(0,3):pt(e,l);return jsxs("article",{style:H(o),className:b("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&&jsx("header",{className:"mx-auto mb-8 max-w-4xl sm:mb-12 lg:mb-16",children:jsxs(Y,{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:[jsx(ArrowLeft,{className:"h-4 w-4 transition-transform group-hover:-translate-x-1 sm:h-5 sm:w-5","aria-hidden":"true"}),jsxs("span",{className:"text-sm font-medium sm:text-base",children:[jsx("span",{className:"hidden sm:inline",children:r.backToHome.label??"Back to all articles"}),jsx("span",{className:"sm:hidden",children:"Back"})]})]})}),jsx("style",{children:`
|
|
1
|
+
import ee from'next/link.js';import mt from'next/image.js';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {ChevronLeftIcon,ChevronRightIcon,MoreHorizontalIcon,ChevronsLeft,ChevronsRight,Check,ArrowUpRight,ArrowLeft,Globe,Mail,Copy,Share2}from'lucide-react';import {Slot}from'@radix-ui/react-slot';import {cva}from'class-variance-authority';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {format,formatDistanceToNow}from'date-fns';import*as Ge from'react';import Ge__default,{useState,useSyncExternalStore,useMemo,useEffect}from'react';import {MDXRemote}from'next-mdx-remote-client/rsc';import {FaXTwitter,FaLinkedinIn,FaGithub}from'react-icons/fa6';import*as ft from'@radix-ui/react-separator';import $n from'rehype-raw';import Dn,{defaultSchema}from'rehype-sanitize';import Un from'remark-gfm';import Hn from'remark-toc';import jn from'rehype-slug';import {createHash}from'crypto';import {Ratelimit}from'@upstash/ratelimit';import {Redis}from'@upstash/redis';import {eq,and,desc,sql}from'drizzle-orm';import {sqliteTable,integer,text,uniqueIndex}from'drizzle-orm/sqlite-core';import {NextResponse}from'next/server.js';function b(...e){return twMerge(clsx(e))}var $e=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 $r({className:e,variant:t,size:r,asChild:n=false,...o}){return jsx(n?Slot:"button",{"data-slot":"button",className:b($e({variant:t,size:r,className:e})),...o})}function et({className:e,...t}){return jsx("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:b("mx-auto flex w-full justify-center",e),...t})}function tt({className:e,...t}){return jsx("ul",{"data-slot":"pagination-content",className:b("flex flex-row items-center gap-1",e),...t})}function Z({...e}){return jsx("li",{"data-slot":"pagination-item",...e})}function oe({className:e,isActive:t,size:r="icon",...n}){return jsx("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,className:b($e({variant:t?"outline":"ghost",size:r}),e),...n})}function rt({className:e,...t}){return jsxs(oe,{"aria-label":"Go to previous page",size:"default",className:b("gap-1 px-2.5 sm:pl-2.5",e),...t,children:[jsx(ChevronLeftIcon,{}),jsx("span",{className:"hidden sm:block",children:"Previous"})]})}function nt({className:e,...t}){return jsxs(oe,{"aria-label":"Go to next page",size:"default",className:b("gap-1 px-2.5 sm:pr-2.5",e),...t,children:[jsx("span",{className:"hidden sm:block",children:"Next"}),jsx(ChevronRightIcon,{})]})}function De({className:e,...t}){return jsxs("span",{"aria-hidden":true,"data-slot":"pagination-ellipsis",className:b("flex size-9 items-center justify-center",e),...t,children:[jsx(MoreHorizontalIcon,{className:"size-4"}),jsx("span",{className:"sr-only",children:"More pages"})]})}function ge({currentPage:e,totalPages:t,baseUrl:r,className:n,maxVisiblePages:o=5,showPrevNext:i=true,showFirstLast:s=true}){if(t<=1)return null;let c=()=>{let g=Math.floor(o/2),p=Math.max(1,e-g),x=Math.min(t,p+o-1);return x-p+1<o&&(p=Math.max(1,x-o+1)),{start:p,end:x}},{start:l,end:u}=c(),m=Array.from({length:u-l+1},(g,p)=>l+p),a=g=>g===1?r:`${r}?page=${g}`,f=e>1,h=e<t;return jsxs(et,{className:n,children:[jsxs(tt,{children:[s&&e>2&&jsxs(Fragment,{children:[jsx(Z,{children:jsx(oe,{href:a(1),"aria-label":"Go to first page",children:jsx(ChevronsLeft,{className:"h-4 w-4"})})}),l>2&&jsx(Z,{children:jsx(De,{})})]}),i&&jsx(Z,{children:f?jsx(rt,{href:a(e-1)}):jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pl-2.5",children:jsx("span",{className:"hidden sm:block",children:"Previous"})})}),m.map(g=>jsx(Z,{children:jsx(oe,{href:a(g),isActive:g===e,children:g})},g)),i&&jsx(Z,{children:h?jsx(nt,{href:a(e+1)}):jsx("span",{className:"flex h-9 items-center justify-center gap-1 px-2.5 text-muted-foreground sm:pr-2.5",children:jsx("span",{className:"hidden sm:block",children:"Next"})})}),s&&e<t-1&&jsxs(Fragment,{children:[u<t-1&&jsx(Z,{children:jsx(De,{})}),jsx(Z,{children:jsx(oe,{href:a(t),"aria-label":"Go to last page",children:jsx(ChevronsRight,{className:"h-4 w-4"})})})]})]}),jsxs("div",{className:"sr-only","aria-live":"polite",children:["Page ",e," of ",t]})]})}function zr(e,t=10){let r=e.page,n=Array.isArray(r)?r[0]:r,o=Math.max(1,parseInt(n??"1",10)),i=(o-1)*t;return {currentPage:o,itemsPerPage:t,offset:i,calculateTotalPages:c=>Math.ceil(c/t)}}function Vr(e,t,r,n){let o=n?`${n}${e===1?r:`${r}?page=${e}`}`:void 0,i=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:{...o&&{canonical:o}},other:{...i&&{prev:i},...s&&{next:s}}}}function E(e="/blog"){let t=e.trim();return !t||t==="/"?"":t.replace(/^(?!\/)/,"/").replace(/\/+$/,"")}function N(e,t){let r=E(e),n=t?.replace(/^\/+/,"").replace(/\/+$/,"");return n?`${r}/${n}`.replace(/\/+/g,"/"):r||"/"}function _(e,t){return N(e,`authors/${t}`)}function qr(e){let t=new URL(e);return E(t.pathname)}function Ue(e,t={}){let{customDomain:r,pathPrefix:n="/blog",language:o,isAccessibleForFree:i=true,includeOptionalProperties:s=true}=t,c=r??e.site.domain,l=r?`https://${c}${n}/${e.slug}`:e.meta.canonicalUrl??`https://${c}${n}/${e.slug}`,u=e.author?He(e.author,{customDomain:r,pathPrefix:n}):void 0,m=ot(e.site,{customDomain:r,pathPrefix:n}),f=`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:u,publisher:m,mainEntityOfPage:{"@type":"WebPage","@id":l},wordCount:e.wordCount,timeRequired:f,isAccessibleForFree:i};return s&&(e.featuredImage&&(h.image=e.featuredImage),e.meta.keywords.length>0&&(h.keywords=[...e.meta.keywords]),(o??e.site.locale)&&(h.inLanguage=o??e.site.locale),e.site.toneAdjectives.length>0&&(h.about=e.site.toneAdjectives.map(g=>({"@type":"Thing",name:g}))),e.site.toneAdjectives.length>0&&(h.genre=[...e.site.toneAdjectives])),h}function He(e,t={}){let{customDomain:r,pathPrefix:n="/blog"}=t,o={"@context":"https://schema.org","@type":"Person","@id":`#author-${e.id}`,name:e.name,identifier:e.id};e.bio&&(o.description=e.bio),e.avatarUrl&&(o.image=e.avatarUrl);let i=[e.socialLinks?.website,e.socialLinks?.x,e.socialLinks?.linkedin,e.socialLinks?.github].filter(s=>!!s);if(i.length>0&&(o.sameAs=i),e.slug?.trim()){let s=r?`https://${r}${_(n,e.slug)}`:_(n,e.slug);o.url=s;}return e.isGuest&&(o.additionalType="GuestAuthor"),e.toneAdjectives&&e.toneAdjectives.length>0&&(o.knowsAbout=[...e.toneAdjectives]),o}function ot(e,t={}){let{customDomain:r,pathPrefix:n="/blog"}=t,i=`https://${r??e.domain}${n}`,s={"@context":"https://schema.org","@type":"Organization","@id":`${i}#organization`,name:e.name,url:i};return e.description?.trim()&&(s.description=e.description),e.tagline?.trim()&&(s.description=s.description?`${s.description}. ${e.tagline}`:e.tagline),s}function st(e,t={}){let{customDomain:r,pathPrefix:n="/blog",language:o,includeSearchAction:i=true}=t,c=`https://${r??e.domain}${n}`,l=ot(e,t),u={"@context":"https://schema.org","@type":"WebSite","@id":`${c}#website`,name:e.name,url:c,publisher:l};return e.description?.trim()&&(u.description=e.description),(o??e.locale)&&(u.inLanguage=o??e.locale),i&&(u.potentialAction={"@type":"SearchAction",target:{"@type":"EntryPoint",urlTemplate:`${c}?search={search_term_string}`},"query-input":"required name=search_term_string"}),u}function Mt(e,t={}){let{customDomain:r}=t;return {"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:e.map((n,o)=>({"@type":"ListItem",position:o+1,name:n.name,item:r&&!n.url.startsWith("http")?`https://${r}${n.url}`:n.url}))}}function at(e,t={}){let r=[];r.push(Ue(e,t)),r.push(st(e.site,t));let n=t.pathPrefix??"/blog",o=[{name:"Home",url:"/"},{name:e.site.name,url:n},{name:e.title,url:`${n}/${e.slug}`}];return r.push(Mt(o,t)),r}function lt(e,t=[],r={}){let n=[];if(n.push(st(e,r)),t.length>0){let o=t.slice(0,5).map(i=>Ue(i,r));n.push(...o);}return n}function $t(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 Dt(e){return JSON.stringify(e,null,0)}function se(e){return {type:"application/ld+json",dangerouslySetInnerHTML:{__html:Dt(e)}}}function Xr(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 Ne=class extends Error{constructor(r,n,o){super(r);this.code=n;this.details=o;this.name="StructuredDataError";}code;details};function Wr(e,t={}){try{let r=Ue(e,t),n=$t(r);return n.isValid?{schema:r}:{error:new Ne("Generated schema validation failed","VALIDATION_FAILED",n.errors)}}catch(r){return {error:new Ne("Failed to generate structured data","GENERATION_FAILED",r)}}}var V="bg-linear-to-br from-[var(--blog-accent-hover)] via-[var(--blog-text-accent)] to-fuchsia-200 bg-clip-text text-transparent",fe={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 j(e={}){return {"--blog-accent":e.accentColor??fe.accentColor,"--blog-accent-hover":e.accentHoverColor??fe.accentHoverColor,"--blog-text-accent":e.textAccentColor??e.accentColor??fe.textAccentColor,"--blog-text-accent-hover":e.textAccentHoverColor??e.accentHoverColor??fe.textAccentHoverColor,"--blog-accent-bg":e.accentBackgroundColor??fe.accentBackgroundColor,"--blog-accent-border":e.accentBorderColor??fe.accentBorderColor}}function ct(e,t){let r=new Date(e),n=new Date(t);return {publishedDateLabel:format(r,"d MMMM yyyy"),publishedRelativeLabel:formatDistanceToNow(r,{addSuffix:true}),updatedDateLabel:format(n,"d MMMM yyyy"),isUpdated:n.getTime()!==r.getTime()}}function ut(e){let t=[],r=false;for(let n of e.split(`
|
|
2
|
+
`)){if(/^\s*```/.test(n)){r=!r;continue}if(r)continue;let o=/^(#{2,3})\s+(.+?)\s*#*\s*$/.exec(n);if(!o?.[1]||!o[2])continue;let i=Jr(o[2]);i&&t.push({id:Yr(i),text:i,level:o[1].length});}return t}function Ht(e){return `${e} ${e===1?"section":"sections"}`}function jt(e,t){let r=e===t;return {isActive:r,ariaCurrent:r?"location":void 0}}function Jr(e){return e.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/[*_`~]/g,"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim()}function Yr(e){return e.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-")}var Fe="Thanks, you're on the list. We'll confirm before sending updates.";function Te({siteId:e,settings:t,sourceSurface:r,sourceArticleSlug:n,sourceUrl:o,previewMode:i=false,className:s}){let[c,l]=useState(null),[u,m]=useState(null),[a,f]=useState(false),[h,g]=useState(false),p=nn(e),x=useSyncExternalStore(an,()=>on(p),()=>false),S=a||!i&&x;async function $(A){A.preventDefault(),m(null),l(null);let C=new FormData(A.currentTarget),H=dt(C,"company");if(i){l(Fe),f(true),A.currentTarget.reset();return}g(true);try{let pe=await fetch(`${t.captureBaseUrl.replace(/\/$/,"")}/api/newsletter/subscribe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({siteId:Number(e),publicSubscribeToken:t.publicSubscribeToken,email:dt(C,"email"),name:rn(C,"name"),sourceSurface:r,sourceUrl:tn(o),sourceArticleSlug:n??null,honeypot:H})});if(!pe.ok)throw new Error("Newsletter signup failed.");let Ze=await pe.json().catch(()=>null),Ir=ln(Ze)??Fe;sn(p),l(Ir),f(!0),A.currentTarget.reset();}catch{l(null),m("Newsletter signup failed. Please try again.");}finally{g(false);}}return jsx("section",{className:b("border-y border-[var(--blog-accent-border)] py-5 sm:py-6",s),"aria-labelledby":`newsletter-${r}-title`,children:jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.4fr)] lg:items-end",children:[jsxs("div",{className:"max-w-xl space-y-1",children:[jsx("h2",{id:`newsletter-${r}-title`,className:"text-base leading-6 font-semibold",children:t.title}),jsx("p",{className:"text-muted-foreground text-sm leading-6",children:t.description})]}),S?jsxs("div",{className:"flex items-start gap-3 text-sm leading-6 text-emerald-500",role:"status","aria-live":"polite",children:[jsx("span",{className:"mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-emerald-500/15",children:jsx(Check,{className:"size-3.5","aria-hidden":"true"})}),jsx("p",{children:c??Fe})]}):jsxs("form",{onSubmit:$,className:"space-y-3",children:[jsxs("div",{className:"grid gap-2 sm:grid-cols-[minmax(0,0.8fr)_minmax(0,1fr)_auto]",children:[jsx("label",{className:"sr-only",htmlFor:`newsletter-name-${r}`,children:"Name"}),jsx("input",{id:`newsletter-name-${r}`,name:"name",type:"text",autoComplete:"name",placeholder:"Name",className:"border-input bg-background text-foreground placeholder:text-muted-foreground focus-visible:ring-ring min-h-10 rounded-md border px-3 py-2 text-sm focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none"}),jsx("label",{className:"sr-only",htmlFor:`newsletter-email-${r}`,children:"Email"}),jsx("input",{id:`newsletter-email-${r}`,name:"email",type:"email",autoComplete:"email",placeholder:"Email address",required:true,className:"border-input bg-background text-foreground placeholder:text-muted-foreground focus-visible:ring-ring min-h-10 rounded-md border px-3 py-2 text-sm focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none"}),jsx("input",{type:"text",name:"company",tabIndex:-1,autoComplete:"off","aria-hidden":"true",className:"hidden"}),jsxs("button",{type:"submit",disabled:h,className:"inline-flex min-h-10 w-full shrink-0 items-center justify-center gap-2 rounded-full bg-[var(--blog-accent)] px-5 py-2 text-sm font-semibold text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60 sm:w-auto",children:[h?"Submitting...":t.buttonLabel,jsx(ArrowUpRight,{className:"size-4","aria-hidden":"true"})]})]}),u&&jsx("p",{className:"text-sm text-red-600",children:u})]})]})})}function tn(e){return e?.startsWith("http://")||e?.startsWith("https://")?e:typeof window<"u"?window.location.href:null}function dt(e,t){let r=e.get(t);return typeof r=="string"?r:""}function rn(e,t){let r=dt(e,t).trim();return r.length===0?null:r}function nn(e){return `bloggy_newsletter_subscribed_${e}`}function on(e){if(typeof window>"u")return false;try{if(window.localStorage.getItem(e)==="true")return !0}catch{}return typeof document>"u"?false:document.cookie.split(";").some(t=>t.trim().startsWith(`${e}=true`))}function sn(e){if(typeof window<"u")try{window.localStorage.setItem(e,"true");}catch{}typeof document<"u"&&(document.cookie=`${e}=true; Max-Age=31536000; Path=/; SameSite=Lax`);}function an(e){return typeof window>"u"?()=>{}:(window.addEventListener("storage",e),()=>window.removeEventListener("storage",e))}function ln(e){return e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"?e.message:null}function Vt({articles:e,siteName:t,siteTagline:r,className:n,site:o,includeStructuredData:i=false,basePath:s="/blog",pagination:c,theme:l,newsletter:u,newsletterPreviewMode:m=false}){let a=E(s)||"/",f=u??o?.newsletter,h=o?.id??e[0]?.site.id;return jsxs("div",{style:j(l),className:b("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&&jsxs("header",{className:"blog-header mb-8 text-center sm:mb-12 lg:mb-16",children:[jsx("h1",{className:b("blog-title mb-2 text-3xl font-light tracking-tight text-balance sm:text-4xl lg:text-5xl",V),children:t}),r&&jsx("p",{className:"blog-tagline text-muted-foreground text-base sm:text-lg",children:r}),jsxs("nav",{"aria-label":"Browse blog",className:"mt-5 flex flex-wrap items-center justify-center gap-2 text-sm",children:[jsx(ee,{href:a,"aria-current":"page",className:"rounded-full border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] px-3 py-1.5 font-medium text-[var(--blog-text-accent)] transition-colors hover:border-[var(--blog-text-accent)] hover:text-[var(--blog-text-accent-hover)] hover:no-underline",children:"All articles"}),jsx(ee,{href:N(a,"topics"),className:"text-muted-foreground rounded-full border border-transparent px-3 py-1.5 font-medium transition-colors hover:border-[var(--blog-accent-border)] hover:text-[var(--blog-accent)] hover:no-underline",children:"Topics"}),jsx(ee,{href:N(a,"authors"),className:"text-muted-foreground rounded-full border border-transparent px-3 py-1.5 font-medium transition-colors hover:border-[var(--blog-accent-border)] hover:text-[var(--blog-accent)] hover:no-underline",children:"Authors"})]})]}),jsxs("main",{className:"articles-list",children:[e.length===0?jsxs("div",{className:"no-articles text-muted-foreground py-16 text-center sm:py-24 lg:py-32",children:[jsx("h2",{className:"mb-3 text-xl font-light sm:mb-4 sm:text-2xl lg:text-3xl",children:"No articles yet"}),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."})]}):jsx("div",{className:"space-y-0",children:e.map(g=>jsx(dn,{article:g,basePath:a},g.id))}),c&&c.totalPages>1&&jsx("div",{className:"pagination-wrapper mt-12",children:jsx(ge,{currentPage:c.currentPage,totalPages:c.totalPages,baseUrl:c.baseUrl??a,className:"justify-center"})})]}),f?.enabled&&h&&jsx(Te,{siteId:h,settings:f,sourceSurface:"blog_home",previewMode:m,className:"mt-10 sm:mt-12"}),i&&o&&(()=>{let g=se(lt(o,e.slice(0,5),{pathPrefix:a}));return jsx("script",{type:g.type,dangerouslySetInnerHTML:g.dangerouslySetInnerHTML})})()]})}function un(e){return `${Math.ceil(e/60)} min read`}function dn({article:e,basePath:t}){let r=N(t,e.slug),n=formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true}),o=un(e.readingSeconds),i=e.featuredImage;return 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:[jsxs("div",{className:"space-y-4 lg:hidden",children:[i&&jsx(ee,{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:jsx(mt,{src:i,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"})}),jsxs("div",{className:"space-y-3",children:[jsx(ee,{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: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})}),jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxs(Fragment,{children:[jsx(Gt,{author:e.author,basePath:t}),jsx("span",{className:"text-border",children:"\u2022"})]}),jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${n}`,children:n}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:o})]}),e.excerpt&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed sm:text-base",children:e.excerpt}),(e.topics??[]).length>0&&jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(s=>jsx(Ft,{topic:s,basePath:t},s.id))})]})]}),jsxs("div",{className:"hidden items-start gap-6 lg:flex xl:gap-8",children:[i&&jsx(ee,{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:jsx(mt,{src:i,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"})}),jsxs("div",{className:"flex min-h-[180px] flex-1 flex-col justify-between space-y-4 xl:min-h-[200px]",children:[jsxs("div",{className:"space-y-4",children:[jsx(ee,{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: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&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-base leading-relaxed xl:text-lg",children:e.excerpt}),(e.topics??[]).length>0&&jsx("div",{className:"flex flex-wrap gap-2",children:(e.topics??[]).map(s=>jsx(Ft,{topic:s,basePath:t},s.id))})]}),jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[e.author&&jsxs(Fragment,{children:[jsx(Gt,{author:e.author,basePath:t}),jsx("span",{className:"text-border",children:"\u2022"})]}),jsx("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${n}`,children:n}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:o})]})]})]})]})}function Ft({topic:e,basePath:t}){let r="rounded-full border border-[var(--blog-accent-border)] px-2.5 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)]",n=e.slug.trim();return n?jsx(ee,{href:N(t,`topics/${n}`),className:r,children:e.name}):jsx("span",{className:r,children:e.name})}function Gt({author:e,basePath:t}){return jsxs(ee,{href:_(t,e.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsx(mn,{author:e,size:"sm"}),e.name]})}function mn({author:e,size:t}){let r=t==="md"?"h-9 w-9 text-sm":"h-6 w-6 text-xs",n=pn(e.name);return e.avatarUrl?jsx(mt,{src:e.avatarUrl,alt:e.name,width:t==="md"?36:24,height:t==="md"?36:24,className:b("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsx("span",{className:b("bg-muted inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function pn(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function gn(e,t,r,n,o="/blog"){let i=e?`${e} - Blog`:"Blog",s=n&&n.currentPage>1?`${i} - Page ${n.currentPage}`:i,c=t??"Read our latest articles and insights.",l=E(o)||"/",u=r?`${r}${n&&n.currentPage>1?`${l}?page=${n.currentPage}`:l}`:void 0,m=n&&n.currentPage>1&&r?`${r}${n.currentPage===2?l:`${l}?page=${n.currentPage-1}`}`:void 0,a=n&&n.currentPage<n.totalPages&&r?`${r}${l}?page=${n.currentPage+1}`:void 0;return {title:s,description:c,openGraph:{title:s,description:c,type:"website",...r&&{url:u}},twitter:{card:"summary_large_image",title:s,description:c},alternates:{...u&&{canonical:u}},other:{...m&&{prev:m},...a&&{next:a}}}}var hn=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 Re({className:e,variant:t,...r}){return jsx("div",{className:b(hn({variant:t}),e),...r})}function Ce({className:e,...t}){return jsx("div",{"data-slot":"card",className:b("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...t})}function xn({className:e,...t}){return jsx("div",{"data-slot":"card-header",className:b("@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 yn({className:e,...t}){return jsx("div",{"data-slot":"card-title",className:b("leading-none font-semibold",e),...t})}function vn({className:e,...t}){return jsx("div",{"data-slot":"card-description",className:b("text-muted-foreground text-sm",e),...t})}function Le({className:e,...t}){return jsx("div",{"data-slot":"card-content",className:b("px-6",e),...t})}function Pn({className:e,...t}){return jsx("div",{"data-slot":"card-footer",className:b("flex items-center px-6 [.border-t]:pt-6",e),...t})}function Nn(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 qt(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 Tn(e,t=globalThis.navigator){return t?.share?(await t.share({title:e.title,url:e.url}),"shared"):(await qt(e.url,t?.clipboard),"copied")}function ze({title:e,url:t,className:r,size:n="md"}){let[o,i]=Ge__default.useState(false),[s,c]=Ge__default.useState(false),l=Ge__default.useMemo(()=>Nn(t,typeof window>"u"?void 0:window.location.href),[t]);Ge__default.useEffect(()=>{if(!o)return;let h=window.setTimeout(()=>i(false),2e3);return ()=>window.clearTimeout(h)},[o]);async function u(){await qt(l),i(true);}async function m(){c(true);try{await Tn({title:e,url:l})==="copied"&&i(!0);}finally{c(false);}}let a=n==="sm"?"h-8 gap-1.5 px-2.5 text-xs":"h-9 gap-2 px-3 text-sm",f=n==="sm"?"size-3.5":"size-4";return jsxs("div",{className:b("article-top-actions flex flex-wrap items-center justify-center gap-2",r),children:[jsxs("button",{type:"button","aria-label":"Copy article link",onClick:u,className:b("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)]",a),children:[o?jsx(Check,{className:f,"aria-hidden":"true"}):jsx(Copy,{className:f,"aria-hidden":"true"}),jsx("span",{children:o?"Copied":"Copy link"})]}),jsxs("button",{type:"button","aria-label":"Share article",onClick:m,disabled:s,className:b("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",a),children:[jsx(Share2,{className:f,"aria-hidden":"true"}),jsx("span",{children:"Share"})]})]})}function Wt({alt:e="",className:t,src:r,...n}){if(typeof r!="string"||r.length===0)return jsx("img",{alt:e,className:t,...n});let o=`blog-image-preview-${Cn(r)}`,i=Rn(r);return jsxs(Fragment,{children:[jsx("a",{href:`#${o}`,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:jsx("img",{src:r,alt:e,className:b("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})}),jsxs("div",{id:o,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:[jsx("a",{href:"#article-content",className:"absolute inset-0 bg-black/85 backdrop-blur-sm","aria-label":"Close image preview"}),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:jsx("img",{src:i,alt:e,className:"pointer-events-auto h-[88vh] w-[94vw] rounded-3xl object-contain shadow-2xl"})}),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 Rn(e){if(!e.includes("/cdn-cgi/image/"))return e;try{let t=new URL(e),r=t.pathname.split("/"),n=r.findIndex(o=>o==="image");return n===-1||r[n-1]!=="cdn-cgi"||!r[n+1]?e:(r[n+1]="width=1600,quality=90,format=webp",t.pathname=r.join("/"),t.toString())}catch{return e}}function Cn(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 gt({items:e,contentId:t,variant:r,showProgress:n=true}){let o=e[0]?.id??null,i=useMemo(()=>e.map(s=>s.id),[e]);return jsxs(Fragment,{children:[jsx(In,{contentId:t,itemIds:i}),n&&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}),jsx(En,{items:e,activeItemId:o,variant:r})]})}function In({contentId:e,itemIds:t}){return useEffect(()=>{let r=0,n=decodeURIComponent(window.location.hash.replace(/^#/,"")),o=l=>{let u=Array.from(document.querySelectorAll("[data-blog-toc-link]"));for(let m of u){let a=m.getAttribute("data-blog-toc-link")===l;m.setAttribute("data-active",a?"true":"false"),a?m.setAttribute("aria-current","location"):m.removeAttribute("aria-current");}},i=()=>{let l=document.getElementById(e);if(!l)return;let u=Array.from(document.querySelectorAll(`[data-blog-reading-progress="${e}"]`)),m=l.getBoundingClientRect(),a=window.scrollY,f=m.top+a,h=l.offsetHeight-window.innerHeight,g=h<=0?a>=f?100:0:(a-f)/h*100,p=Bn(g);for(let A of u)A.style.transform=`scaleX(${p/100})`,A.setAttribute("aria-valuenow",String(Math.round(p)));let x=t.map(A=>document.getElementById(A)).filter(A=>!!A);if(n&&t.includes(n)){o(n),n="";return}let S=Math.max(160,Math.round(window.innerHeight*.33)),$=x.filter(A=>A.getBoundingClientRect().top<=S).at(-1)??x[0]??null;o($?$.id:null);},s=()=>{window.cancelAnimationFrame(r),r=window.requestAnimationFrame(i);},c=()=>{n=decodeURIComponent(window.location.hash.replace(/^#/,"")),s();};return s(),window.addEventListener("scroll",s,{passive:true}),window.addEventListener("resize",s),window.addEventListener("hashchange",c),()=>{window.cancelAnimationFrame(r),window.removeEventListener("scroll",s),window.removeEventListener("resize",s),window.removeEventListener("hashchange",c);}},[e,t]),null}function Bn(e){return Number.isFinite(e)?Math.min(100,Math.max(0,e)):0}function En({items:e,activeItemId:t,variant:r}){if(e.length===0)return null;let n=jsx("ul",{className:"space-y-2 text-sm",children:e.map(o=>{let i=jt(o.id,t);return jsx("li",{className:o.level===3?"pl-4":void 0,children:jsx("a",{href:`#${o.id}`,"aria-current":i.ariaCurrent,"data-blog-toc-link":o.id,"data-active":i.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:o.text})},o.id)})});return r==="mobile"?jsxs("details",{className:"group mb-6 rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] lg:hidden",children:[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:[jsx("span",{children:"On this page"}),jsxs("span",{className:"text-muted-foreground flex items-center gap-2 text-xs font-medium",children:[Ht(e.length),jsx("span",{className:"text-[var(--blog-text-accent)] transition-transform group-open:rotate-180","aria-hidden":"true",children:"\u2193"})]})]}),jsx("nav",{"aria-label":"Table of contents",className:"border-t border-[var(--blog-accent-border)] px-4 py-4",children:n})]}):jsx("aside",{className:"hidden lg:block",children: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:[jsx("p",{className:"text-muted-foreground mb-3 text-xs font-semibold tracking-wider uppercase",children:"On this page"}),n]})})}var le=Ge.forwardRef(({className:e,orientation:t="horizontal",decorative:r=true,...n},o)=>jsx(ft.Root,{ref:o,decorative:r,orientation:t,className:b("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...n}));le.displayName=ft.Root.displayName;var Fn=defaultSchema.attributes?.["*"]??[],Gn=defaultSchema.attributes?.a??[],zn=defaultSchema.attributes?.img??[],Vn={...defaultSchema,tagNames:[...defaultSchema.tagNames??[],"figure","figcaption"],attributes:{...defaultSchema.attributes,"*":[...Fn,"className"],a:[...Gn,"className","href","target","rel","title"],img:[...zn,"className","src","alt","title","width","height","loading"],figure:["className"],figcaption:["className"],span:["className"]},protocols:{...defaultSchema.protocols,href:["http","https","mailto","tel"],src:["http","https"]}},Jt={mdxOptions:{format:"md",remarkPlugins:[Hn,Un],rehypePlugins:[$n,[Dn,Vn],qn,jn]}};function qn(){return e=>{Yt(e);}}function Yt(e){e.children&&(e.children=e.children.flatMap(t=>(Yt(t),Xn(t)?t.children?.filter(ht)??[t]:[t])));}function Xn(e){if(e.type!=="element"||e.tagName!=="p"||!e.children)return false;let t=e.children.filter(ht);return t.length===1&&Wn(t[0])}function Wn(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(ht);return t.length===1&&t[0]?.tagName==="img"}function ht(e){return e.type!=="text"||!!e.value?.trim()}function bt(e,t,r={}){let n=r.limit??3;if(n<=0)return [];let o=Qt(e),i=Kn(e,t),s=(m,a)=>Zt(a)-Zt(m)||er(m).localeCompare(er(a)),c=o?i.filter(m=>Qt(m)===o).sort(s):[],l=new Set(c.map(m=>m.id)),u=i.filter(m=>!l.has(m.id)).sort(s);return [...c,...u].slice(0,n)}function Kn(e,t){let r=new Set,n=new Set,o=[];for(let i of t)i.id===e.id||i.slug===e.slug||r.has(i.id)||n.has(i.slug)||(r.add(i.id),n.add(i.slug),o.push(i));return o}function Qt(e){let t=e.topics??[];return t.find(r=>r.isPrimary)?.slug??t[0]?.slug??null}function Zt(e){let t=Date.parse(e.publishedAt??e.updatedAt??"");return Number.isFinite(t)?t:0}function er(e){return e.title??e.slug}function ei(e){return `${Math.ceil(e/60)} min read`}function ti(e){try{return new URL(e).hostname.replace(/^www\./,"")}catch{return e}}function ri({creditText:e,creditUrl:t}){if(!e&&!t)return null;let r=e??ti(t??"");return jsxs("span",{children:["Credit:"," ",t?jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 transition-colors hover:text-[var(--blog-text-accent)]",children:r}):r]})}function sr({article:e,className:t,navigation:r,basePath:n="/blog",theme:o,postArticleCta:i,newsletter:s,newsletterPreviewMode:c=false,articles:l=[],relatedArticles:u=[],showShareLinks:m=true}){let a=E(n)||"/",f=ct(e.publishedAt,e.updatedAt),h=ei(e.readingSeconds),g=ut(e.content),p=e.meta.canonicalUrl??N(a,e.slug),x=s??e.site.newsletter,S=i??e.cta,$=e.featuredImage,A=!!(e.featuredImageCaption??e.featuredImageCreditText??e.featuredImageCreditUrl),C=u.length>0?u.slice(0,3):bt(e,l);return jsxs("article",{style:j(o),className:b("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&&jsx("header",{className:"mx-auto mb-8 max-w-4xl sm:mb-12 lg:mb-16",children:jsxs(ee,{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:[jsx(ArrowLeft,{className:"h-4 w-4 transition-transform group-hover:-translate-x-1 sm:h-5 sm:w-5","aria-hidden":"true"}),jsxs("span",{className:"text-sm font-medium sm:text-base",children:[jsx("span",{className:"hidden sm:inline",children:r.backToHome.label??"Back to all articles"}),jsx("span",{className:"sm:hidden",children:"Back"})]})]})}),jsx("style",{children:`
|
|
3
3
|
.article-content figure > p {
|
|
4
4
|
margin-top: 0 !important;
|
|
5
5
|
margin-bottom: 0 !important;
|
|
@@ -36,9 +36,13 @@ import Y from'next/link';import lt from'next/image';import {clsx}from'clsx';impo
|
|
|
36
36
|
text-decoration-line: underline;
|
|
37
37
|
text-underline-offset: 0.18em;
|
|
38
38
|
}
|
|
39
|
-
`}),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:[jsx("h1",{className:b("article-title px-4 text-2xl leading-tight font-light tracking-tight text-balance sm:px-0 sm:text-3xl md:text-4xl lg:text-5xl xl:text-6xl",G),children:e.title}),e.excerpt&&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}),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&&jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"sr-only",children:"Author"}),jsxs(Y,{href:k(s,e.author.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsx(qt,{author:e.author,size:"md"}),e.author.name]}),e.author.isGuest&&jsx(we,{variant:"outline",className:"text-xs",children:"Guest Author"})]}),jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-3 gap-y-1",children:[jsxs("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${f.publishedDateLabel}`,children:["Published ",f.publishedDateLabel]}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:f.publishedRelativeLabel}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:h})]}),f.isUpdated&&jsxs("time",{dateTime:e.updatedAt,className:"text-xs",children:["Updated ",f.updatedDateLabel]}),m&&jsx(He,{title:e.title,url:p,size:"sm"}),jsx("div",{className:"bg-border h-px w-6 sm:w-8","aria-hidden":"true"}),(e.topics??[]).length>0?jsx("nav",{"aria-label":"Article topics",className:"flex flex-wrap justify-center gap-2",children:(e.topics??[]).map(U=>jsx(Y,{href:N((r?.backToHome?.url??"/blog").replace(/\/$/,""),`topics/${U.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:U.name},U.id))}):jsxs("span",{className:"text-xs tracking-wider uppercase sm:text-sm",role:"text",children:["From ",e.site.name]})]})]}),O&&jsxs("figure",{className:"article-featured-image mx-auto my-8 w-full max-w-4xl sm:my-12 lg:my-16",children:[jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-3xl border border-[var(--blog-accent-border)] shadow-[0_24px_80px_rgb(168_85_247_/_0.14)]",children:jsx(lt,{src:O,alt:e.featuredImageAlt??`Featured image for ${e.title}`,className:"h-full w-full object-cover",width:800,height:450,priority:true})}),P&&jsxs("figcaption",{className:"text-muted-foreground mt-3 space-y-1 px-2 text-center text-sm leading-relaxed sm:px-0",children:[e.featuredImageCaption&&jsx("p",{children:e.featuredImageCaption}),(e.featuredImageCreditText??e.featuredImageCreditUrl)&&jsx("p",{className:"text-xs",children:jsx(On,{creditText:e.featuredImageCreditText,creditUrl:e.featuredImageCreditUrl})})]})]}),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:[jsxs("div",{className:"min-w-0",children:[jsx(ut,{items:g,contentId:"article-body",variant:"mobile"}),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)] [&_figure>p]:!my-0 [&_figcaption]:!mt-2 [&_figcaption]:text-center [&_figcaption]:!text-sm [&_figcaption]:!leading-snug [&_figcaption]:text-muted-foreground [&_figcaption_.blog-image-credit]:mt-1 [&_figcaption_.blog-image-credit]:block [&_figcaption_.blog-image-credit]:text-xs [&_figcaption_.blog-image-credit]:tracking-wide [&_figcaption_.blog-image-credit]:text-muted-foreground/80 [&_figcaption>span:not(.blog-image-credit)]:ml-2 [&_figcaption>span:not(.blog-image-credit)]:border-l [&_figcaption>span:not(.blog-image-credit)]:border-[var(--blog-accent-border)] [&_figcaption>span:not(.blog-image-credit)]:pl-2 [&_figcaption>span:not(.blog-image-credit)]:text-xs [&_figcaption>span:not(.blog-image-credit)]:tracking-wide [&_figcaption>span:not(.blog-image-credit)]:text-muted-foreground/80 max-w-none",children:jsx(MDXRemote,{source:e.content,options:Ht,components:{img:Dt}})})]}),jsx(ut,{items:g,contentId:"article-body",variant:"desktop",showProgress:false})]}),e.author?.bio&&jsxs("div",{id:"about-author",className:"author-bio mx-auto mt-12 max-w-4xl",children:[jsx(se,{className:"mb-8"}),jsx(Se,{className:"border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)]",children:jsxs(Ne,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-start sm:p-6",children:[jsx("div",{className:"shrink-0",children:jsx(qt,{author:e.author,size:"lg"})}),jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[jsxs("div",{className:"min-w-0",children:[jsx("p",{className:"text-muted-foreground text-sm font-medium",children:"Written by"}),jsxs("h2",{className:"text-foreground flex flex-wrap items-center gap-2 text-xl font-semibold",children:[jsx(Y,{href:k(s,e.author.slug),className:"transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:e.author.name}),e.author.isGuest&&jsx(we,{variant:"outline",className:"text-xs",children:"Guest Author"})]})]}),jsx(Mn,{author:e.author})]}),jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.author.bio})]})]})})]}),((S??false)||(x?.enabled??false)||m||C.length>0)&&jsxs("div",{className:"mx-auto mt-12 max-w-4xl space-y-8",children:[jsx(se,{}),S&&jsx(Un,{cta:S}),x?.enabled&&jsx(Ae,{siteId:e.site.id,settings:x,sourceSurface:"article",sourceArticleSlug:e.slug,sourceUrl:p,previewMode:c}),m&&jsx(Hn,{title:e.title,url:p}),C.length>0&&jsx(Fn,{articles:C,basePath:s})]}),(!!r?.previousArticle||!!r?.nextArticle)&&jsxs("nav",{className:"article-nav mx-auto mt-12 max-w-4xl",children:[jsx(se,{className:"mb-8"}),jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[r?.previousArticle&&jsx(Se,{className:"group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxs(Y,{href:r.previousArticle.url,className:"block",children:[r.previousArticle.featuredImage&&jsx(gt,{src:r.previousArticle.featuredImage,alt:r.previousArticle.featuredImageAlt??`Featured image for ${r.previousArticle.title}`}),jsxs(Ne,{className:"p-4",children:[jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"\u2190 Previous Article"}),jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.previousArticle.title})]})]})}),r?.nextArticle&&jsx(Se,{className:b("group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",!r?.previousArticle&&"md:col-start-2"),children:jsxs(Y,{href:r.nextArticle.url,className:"block",children:[r.nextArticle.featuredImage&&jsx(gt,{src:r.nextArticle.featuredImage,alt:r.nextArticle.featuredImageAlt??`Featured image for ${r.nextArticle.title}`}),jsxs(Ne,{className:"p-4 md:text-right",children:[jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"Next Article \u2192"}),jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.nextArticle.title})]})]})})]})]}),(()=>{let U=oe(nt(e,{customDomain:e.site.domain,pathPrefix:s}));return jsx("script",{type:U.type,dangerouslySetInnerHTML:U.dangerouslySetInnerHTML})})()]})}function qt({author:e,size:t}){let r=t==="lg"?"h-12 w-12 text-base":"h-9 w-9 text-sm",n=Dn(e.name);return e.avatarUrl?jsx(lt,{src:e.avatarUrl,alt:e.name,width:t==="lg"?48:36,height:t==="lg"?48:36,className:b("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsx("span",{className:b("bg-muted text-muted-foreground inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function Mn({author:e}){let t=$n(e);return t.length===0?null:jsx("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:t.map(r=>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 $n(e){let t=e.socialLinks;return t?[t.website?{key:"website",href:t.website,label:"website",external:true,icon:jsx(Globe,{className:"size-4","aria-hidden":"true"})}:void 0,t.x?{key:"x",href:t.x,label:"on X",external:true,icon:jsx(FaXTwitter,{className:"size-4","aria-hidden":"true"})}:void 0,t.linkedin?{key:"linkedin",href:t.linkedin,label:"on LinkedIn",external:true,icon:jsx(FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}:void 0,t.github?{key:"github",href:t.github,label:"on GitHub",external:true,icon:jsx(FaGithub,{className:"size-4","aria-hidden":"true"})}:void 0,t.email?{key:"email",href:`mailto:${t.email}`,label:"email",external:false,icon:jsx(Mail,{className:"size-4","aria-hidden":"true"})}:void 0].filter(n=>!!n):[]}function Dn(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function Un({cta:e}){return jsx("div",{className:"rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] p-5 sm:p-6",children:jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[jsxs("div",{className:"space-y-1",children:[jsx("h2",{className:"text-foreground text-xl font-semibold",children:e.title}),e.description&&jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.description})]}),jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:flex-row",children:[e.primary&&jsxs(Y,{href:e.primary.href,className:"inline-flex 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.primary.label,jsx(ArrowUpRight,{className:"size-4","aria-hidden":"true"})]}),e.secondary&&jsxs(Y,{href:e.secondary.href,className:"border-border bg-background text-foreground hover:bg-muted inline-flex items-center justify-center gap-2 rounded-full border px-4 py-2 text-sm font-semibold transition-colors",children:[e.secondary.label,jsx(ArrowUpRight,{className:"size-4","aria-hidden":"true"})]})]})]})})}function Hn({title:e,url:t}){let r=encodeURIComponent(e),n=encodeURIComponent(t);return jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2 sm:gap-3",children:[jsx(He,{title:e,url:t,size:"sm"}),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:jsx(FaXTwitter,{className:"size-4","aria-hidden":"true"})}),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:jsx(FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}),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:jsx(Mail,{className:"size-4","aria-hidden":"true"})})]})}function Fn({articles:e,basePath:t}){return jsxs("section",{className:"space-y-4","aria-labelledby":"related-articles-title",children:[jsx("h2",{id:"related-articles-title",className:"text-xl font-semibold",children:"You might also like"}),jsx("div",{className:"grid gap-4 md:grid-cols-3",children:e.map(r=>jsxs(Y,{href:N(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&&jsx(gt,{src:r.featuredImage,alt:r.featuredImageAlt??`Featured image for ${r.title}`}),jsxs("div",{className:"p-4",children:[jsx("h3",{className:"text-foreground line-clamp-3 font-semibold transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.title}),r.excerpt&&jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:r.excerpt})]})]},r.id))})]})}function gt({src:e,alt:t}){return jsx("div",{className:"border-border aspect-[16/9] overflow-hidden border-b bg-[var(--blog-accent-bg)]",children:jsx(lt,{src:e,alt:t,width:480,height:270,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"})})}function Gn(e,t="/blog"){let r=e.meta.title??e.title,n=e.meta.description??e.excerpt,o=e.meta.canonicalUrl??`${e.site.domain}${N(t,e.slug)}`,i=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:o,images:i?[{url:i,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:i?[i]:void 0},alternates:{canonical:o}}}function Zt({author:e,articles:t,site:r,className:n,basePath:o="/blog",theme:i,pagination:a,navigation:c}){let l=B(o)||"/",u=c?.backToHome?.url??l,m=k(l,e.slug),s=a?.totalItems??t.length,f=oe(Me(e,{pathPrefix:l}));return jsxs("main",{style:H(i),className:b("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:[jsxs("header",{className:"mb-10 space-y-8 sm:mb-14",children:[jsxs(Y,{href:u,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:[jsx(ArrowLeft,{className:"size-4 transition-transform group-hover:-translate-x-1","aria-hidden":"true"}),c?.backToHome?.label??"Back to all articles"]}),jsxs("div",{className:"grid gap-6 sm:grid-cols-[auto_minmax(0,1fr)] sm:items-center",children:[jsx(Jn,{author:e}),jsxs("div",{className:"min-w-0 space-y-4",children:[jsxs("div",{className:"space-y-2",children:[jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.isGuest&&jsx(we,{variant:"outline",className:"text-xs",children:"Guest Author"})}),jsx("h1",{className:b("text-4xl leading-tight font-light text-balance sm:text-5xl",G),children:e.name})]}),e.bio&&jsx("p",{className:"text-muted-foreground max-w-3xl text-lg leading-relaxed text-pretty",children:e.bio}),jsx(Xn,{author:e})]})]})]}),jsx(se,{className:"mb-8"}),jsxs("section",{"aria-labelledby":"author-articles-title",className:"space-y-6",children:[jsx("div",{className:"flex flex-wrap items-end justify-between gap-3",children:jsxs("div",{children:[jsxs("h2",{id:"author-articles-title",className:"text-foreground text-2xl font-semibold",children:["Articles by ",e.name]}),jsxs("p",{className:"text-muted-foreground mt-1 text-sm",children:[s," ",s===1?"article":"articles"," on ",r.name]})]})}),t.length===0?jsx("p",{className:"text-muted-foreground border-border rounded-2xl border p-6",children:"This author does not have any published articles yet."}):jsx("div",{className:"divide-border divide-y",children:t.map(h=>jsx(Kn,{article:h,basePath:l},h.id))}),a&&a.totalPages>1&&jsx("div",{className:"pt-4",children:jsx(ue,{currentPage:a.currentPage,totalPages:a.totalPages,baseUrl:a.baseUrl??m,className:"justify-center"})})]}),jsx("script",{type:f.type,dangerouslySetInnerHTML:f.dangerouslySetInnerHTML})]})}function Xn({author:e}){let t=Wn(e);return t.length===0?null:jsx("div",{className:"flex flex-wrap items-center gap-2","aria-label":"Author links",children:t.map(r=>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 Wn(e){let t=e.socialLinks;return t?[t.website?{href:t.website,label:"website",ariaLabel:`${e.name}'s website`,external:true,icon:jsx(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: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: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: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:jsx(Mail,{className:"size-4","aria-hidden":"true"})}:null].filter(r=>r!==null):[]}function Kn({article:e,basePath:t}){let r=formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsx("article",{className:"py-6 first:pt-0 last:pb-0",children:jsxs(Y,{href:N(t,e.slug),className:"group grid gap-4 hover:no-underline sm:grid-cols-[minmax(0,1fr)_12rem] sm:items-start",children:[jsxs("div",{className:"min-w-0 space-y-3",children:[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&&jsx("p",{className:"text-muted-foreground line-clamp-3 leading-relaxed",children:e.excerpt}),jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[jsx("time",{dateTime:e.publishedAt,children:r}),jsx("span",{"aria-hidden":"true",children:"\u2022"}),jsxs("span",{children:[Math.ceil(e.readingSeconds/60)," min read"]})]})]}),e.featuredImage&&jsx("div",{className:"border-border relative aspect-[16/10] overflow-hidden rounded-xl border bg-[var(--blog-accent-bg)]",children:jsx(lt,{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 Jn({author:e}){return e.avatarUrl?jsx(lt,{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}):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:Yn(e.name)})}function Yn(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function Qn(e,t,r="/blog"){let n=`https://${t.domain.replace(/^https?:\/\//,"").replace(/\/+$/,"")}${k(r,e.slug)}`,o=`${e.name} - ${t.name}`,i=e.bio??`Read articles by ${e.name} on ${t.name}.`;return {title:o,description:i,authors:[{name:e.name}],openGraph:{title:o,description:i,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:o,description:i,images:e.avatarUrl?[e.avatarUrl]:void 0},alternates:{canonical:n}}}var Fe=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 i={success:false,error:{code:"PUB003",message:"This URL is already in use. Please choose another."},idempotencyKey:r};return await this.storeOperationResult(r,i),i}this.articles.set(t.slug,t);let o={success:true,url:`/${t.slug}`,platformPostId:t.id,publishedAt:t.publishedAt,idempotencyKey:r};return await this.storeOperationResult(r,o),o}async getArticle(t){return this.articles.get(t)??null}async listArticles(t={}){let{limit:r=10,offset:n=0,sortBy:o="publishedAt",order:i="desc"}=t,a=Array.from(this.articles.values());return a.sort((l,u)=>{let m=new Date(l[o]).getTime(),s=new Date(u[o]).getTime();return i==="desc"?s-m:m-s}),{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 i={success:false,error:{code:"PUB007",message:"Article not found"},idempotencyKey:r};return await this.storeOperationResult(r,i),i}this.articles.delete(t);let o={success:true,idempotencyKey:r};return await this.storeOperationResult(r,o),o}async checkIdempotency(t){return this.operations.get(t)??null}async storeOperationResult(t,r){this.operations.set(t,r);}};function Zn(){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 ei(){let e=globalThis;e.__BLOG_PLATFORM_STORAGE__||(Zn(),e.__BLOG_PLATFORM_STORAGE__=new Fe);let t=e.__BLOG_PLATFORM_STORAGE__;if(!t)throw new Error("Blog platform storage not initialized");return t}function X(){return ei()}function ht(e){let t=globalThis;t.__BLOG_PLATFORM_STORAGE__=e;}function ge(e){let t=new Map;for(let r of e)r.author?.slug&&t.set(r.author.slug,tr(t.get(r.author.slug),r.author));return Array.from(t.values()).sort((r,n)=>r.name.localeCompare(n.name))}function er(e,t){let r=t.filter(o=>o.author?.slug===e).sort((o,i)=>new Date(i.publishedAt).getTime()-new Date(o.publishedAt).getTime()),n=r.reduce((o,i)=>i.author?tr(o,i.author):o,null);return n?{author:n,articles:r}:null}async function ti(e,t={},r=X()){let{articles:n}=await r.listArticles({limit:t.limit??1e3,offset:t.offset??0,sortBy:"publishedAt",order:"desc"});return er(e,n)}function tr(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 ri(e){let t=e.topics??[];return t.find(r=>r.isPrimary)??t[0]??null}function fe(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 bt(e,t){let r=e.filter(o=>(o.topics??[]).some(i=>i.slug===t));if(r.length===0)return null;let n=r.flatMap(o=>o.topics??[]).find(o=>o.slug===t)??null;return n?{topic:n,articles:r}:null}function oi({articles:e,basePath:t="/blog",title:r="Topics",description:n="Browse articles by topic.",className:o,theme:i}){let a=B(t)||"/",c=fe(e);return jsxs("main",{style:H(i),className:b("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",o),children:[jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsx(Y,{href:a,className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all articles"}),jsx("h1",{className:b("text-4xl font-light tracking-tight text-balance sm:text-5xl",G),children:r}),jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),c.length===0?jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No topics have published articles yet."}):jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:c.map(l=>{let u=e.filter(m=>(m.topics??[]).some(s=>s.slug===l.slug)).length;return jsxs(Y,{href:N(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:[jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold transition-colors",children:l.name}),l.description&&jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:l.description}),jsxs("p",{className:"text-muted-foreground mt-4 text-sm",children:[u," ",u===1?"article":"articles"]})]},l.slug)})})]})}function ai({articles:e,topicSlug:t,basePath:r="/blog",className:n,theme:o}){let i=B(r)||"/",a=bt(e,t);return jsxs("main",{style:H(o),className:b("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:[jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsx(Y,{href:N(i,"topics"),className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all topics"}),jsx("h1",{className:b("text-4xl font-light tracking-tight text-balance sm:text-5xl",G),children:a?.topic.name??"Topic not found"}),a?.topic.description&&jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:a.topic.description})]}),a?jsx("div",{className:"grid gap-5 md:grid-cols-2",children:a.articles.map(c=>jsx(si,{article:c,topic:a.topic,basePath:i},c.id))}):jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No published articles were found for this topic."})]})}function si({article:e,topic:t,basePath:r}){let n=N(r,e.slug),o=formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxs(Y,{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&&jsx("div",{className:"relative aspect-[16/9] overflow-hidden",children:jsx(lt,{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"})}),jsxs("div",{className:"space-y-3 p-5",children:[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}),jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold text-balance transition-colors",children:e.title}),e.excerpt&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:e.excerpt}),jsx("p",{className:"text-muted-foreground text-sm",children:o})]})]})}function ci({articles:e,basePath:t="/blog",title:r="Authors",description:n="Browse articles by author.",className:o,theme:i}){let a=B(t)||"/",c=ge(e);return jsxs("main",{style:H(i),className:b("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",o),children:[jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsx(Y,{href:a,className:"text-muted-foreground text-sm font-medium transition-colors hover:text-[var(--blog-accent)]",children:"Back to all articles"}),jsx("h1",{className:b("text-4xl font-light tracking-tight text-balance sm:text-5xl",G),children:r}),jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),c.length===0?jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No authors have published articles yet."}):jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:c.map(l=>{let u=e.filter(m=>m.author?.slug===l.slug).length;return jsx(Y,{href:k(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:jsxs("div",{className:"flex items-start gap-4",children:[jsx(ui,{author:l}),jsxs("div",{className:"min-w-0 space-y-2",children:[jsx("h2",{className:"text-xl font-semibold transition-colors group-hover:text-[var(--blog-accent)]",children:l.name}),l.bio&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:l.bio}),jsxs("p",{className:"text-muted-foreground text-sm",children:[u," ",u===1?"article":"articles"]})]})]})},l.slug)})})]})}function ui({author:e}){let t=di(e.name);return e.avatarUrl?jsx(lt,{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"}):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 di(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function W(e){return `sha256:${createHash("sha256").update(e).digest("hex")}`}function xt(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 i=/^Token\s+(.+)$/i.exec(t);return i?.[1]?i[1]:null}var je=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=>xt(t);hashToken(t){return W(t)}},he=class extends je{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(o=>o.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);}},Le=class{async validateToken(){return {valid:true,context:{development:true}}}extractToken(){return "development-mode"}},ze=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 pi(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??=new ze,globalThis.__BLOG_PLATFORM_AUTH_CONFIG__}function Ve(e){globalThis.__BLOG_PLATFORM_AUTH_CONFIG__=e;}function yt(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??pi()}function gi(e){Ve(new he(e));}async function Z(e){let t=yt(),r=t.extractToken?t.extractToken(e):xt(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 fi(e,t=""){let n=yt().errorMessages??{},o,i;switch(e.errorCode){case "missing":o=n.missing??"Authentication token is required",i="PUB005";break;case "expired":o=n.expired??"Authentication token has expired",i="PUB005";break;default:o=n.invalid??"Invalid authentication credentials",i="PUB005";break}return {success:false,error:{code:i,message:o,details:{authError:e.errorCode??"invalid"}},idempotencyKey:t}}async function re(e){let t=await Z(e);return t.authenticated?{authenticated:true,context:t.result.context}:{authenticated:false,error:fi(t.result)}}function hi(){let e=process.env.SKIP_BLOG_PLATFORM_AUTH;return e==="true"||e==="1"||process.env.NODE_ENV==="test"}function xi(){return globalThis.__BLOG_PLATFORM_RATE_LIMITER__??null}function yi(e){let t=globalThis;t.__BLOG_PLATFORM_RATE_LIMITER__=e;}function qe(e){let{redisUrl:t,redisToken:r,requestsPerMinute:n=5,keyPrefix:o="blog-platform-ratelimit",analytics:i=true}=e,a=new Redis({url:t,token:r}),c=new Ratelimit({redis:a,analytics:i,prefix:o,limiter:Ratelimit.slidingWindow(n,"1m")});yi(c);}function vt(){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}qe({redisUrl:e,redisToken:t}),console.log("Blog platform: Rate limiting configured (5 requests per minute per token)");}async function ir(e){let t=xi();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 or(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 ee(e,t=""){let r=await ir(e);return r.success?{allowed:true,rateLimitResult:r}:{allowed:false,errorResponse:or(r,t)}}function $(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 Xe(e){let{auth:t,storage:r,rateLimit:n,autoRateLimit:o=true}=e;if(!t)throw new Error(`Blog platform initialization failed: 'auth' is required.
|
|
39
|
+
`}),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:[jsx("h1",{className:b("article-title px-4 text-2xl leading-tight font-light tracking-tight text-balance sm:px-0 sm:text-3xl md:text-4xl lg:text-5xl xl:text-6xl",V),children:e.title}),e.excerpt&&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}),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&&jsxs("div",{className:"flex items-center gap-2",children:[jsx("span",{className:"sr-only",children:"Author"}),jsxs(ee,{href:_(a,e.author.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsx(rr,{author:e.author,size:"md"}),e.author.name]}),e.author.isGuest&&jsx(Re,{variant:"outline",className:"text-xs",children:"Guest Author"})]}),jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-3 gap-y-1",children:[jsxs("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${f.publishedDateLabel}`,children:["Published ",f.publishedDateLabel]}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:f.publishedRelativeLabel}),jsx("span",{className:"text-border",children:"\u2022"}),jsx("span",{className:"font-medium",children:h})]}),f.isUpdated&&jsxs("time",{dateTime:e.updatedAt,className:"text-xs",children:["Updated ",f.updatedDateLabel]}),m&&jsx(ze,{title:e.title,url:p,size:"sm"}),jsx("div",{className:"bg-border h-px w-6 sm:w-8","aria-hidden":"true"}),(e.topics??[]).length>0?jsx("nav",{"aria-label":"Article topics",className:"flex flex-wrap justify-center gap-2",children:(e.topics??[]).map(H=>jsx(ee,{href:N((r?.backToHome?.url??"/blog").replace(/\/$/,""),`topics/${H.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:H.name},H.id))}):jsxs("span",{className:"text-xs tracking-wider uppercase sm:text-sm",role:"text",children:["From ",e.site.name]})]})]}),$&&jsxs("figure",{className:"article-featured-image mx-auto my-8 w-full max-w-4xl sm:my-12 lg:my-16",children:[jsx("div",{className:"aspect-[16/9] overflow-hidden rounded-3xl border border-[var(--blog-accent-border)] shadow-[0_24px_80px_rgb(168_85_247_/_0.14)]",children:jsx(mt,{src:$,alt:e.featuredImageAlt??`Featured image for ${e.title}`,className:"h-full w-full object-cover",width:800,height:450,priority:true})}),A&&jsxs("figcaption",{className:"text-muted-foreground mt-3 space-y-1 px-2 text-center text-sm leading-relaxed sm:px-0",children:[e.featuredImageCaption&&jsx("p",{children:e.featuredImageCaption}),(e.featuredImageCreditText??e.featuredImageCreditUrl)&&jsx("p",{className:"text-xs",children:jsx(ri,{creditText:e.featuredImageCreditText,creditUrl:e.featuredImageCreditUrl})})]})]}),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:[jsxs("div",{className:"min-w-0",children:[jsx(gt,{items:g,contentId:"article-body",variant:"mobile"}),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)] [&_figure>p]:!my-0 [&_figcaption]:!mt-2 [&_figcaption]:text-center [&_figcaption]:!text-sm [&_figcaption]:!leading-snug [&_figcaption]:text-muted-foreground [&_figcaption_.blog-image-credit]:mt-1 [&_figcaption_.blog-image-credit]:block [&_figcaption_.blog-image-credit]:text-xs [&_figcaption_.blog-image-credit]:tracking-wide [&_figcaption_.blog-image-credit]:text-muted-foreground/80 [&_figcaption>span:not(.blog-image-credit)]:ml-2 [&_figcaption>span:not(.blog-image-credit)]:border-l [&_figcaption>span:not(.blog-image-credit)]:border-[var(--blog-accent-border)] [&_figcaption>span:not(.blog-image-credit)]:pl-2 [&_figcaption>span:not(.blog-image-credit)]:text-xs [&_figcaption>span:not(.blog-image-credit)]:tracking-wide [&_figcaption>span:not(.blog-image-credit)]:text-muted-foreground/80 max-w-none",children:jsx(MDXRemote,{source:e.content,options:Jt,components:{img:Wt}})})]}),jsx(gt,{items:g,contentId:"article-body",variant:"desktop",showProgress:false})]}),e.author?.bio&&jsxs("div",{id:"about-author",className:"author-bio mx-auto mt-12 max-w-4xl",children:[jsx(le,{className:"mb-8"}),jsx(Ce,{className:"border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)]",children:jsxs(Le,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-start sm:p-6",children:[jsx("div",{className:"shrink-0",children:jsx(rr,{author:e.author,size:"lg"})}),jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[jsxs("div",{className:"min-w-0",children:[jsx("p",{className:"text-muted-foreground text-sm font-medium",children:"Written by"}),jsxs("h2",{className:"text-foreground flex flex-wrap items-center gap-2 text-xl font-semibold",children:[jsx(ee,{href:_(a,e.author.slug),className:"transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:e.author.name}),e.author.isGuest&&jsx(Re,{variant:"outline",className:"text-xs",children:"Guest Author"})]})]}),jsx(ni,{author:e.author})]}),jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.author.bio})]})]})})]}),((S??false)||(x?.enabled??false)||m||C.length>0)&&jsxs("div",{className:"mx-auto mt-12 max-w-4xl space-y-8",children:[jsx(le,{}),S&&jsx(si,{cta:S}),x?.enabled&&jsx(Te,{siteId:e.site.id,settings:x,sourceSurface:"article",sourceArticleSlug:e.slug,sourceUrl:p,previewMode:c}),m&&jsx(ai,{title:e.title,url:p}),C.length>0&&jsx(li,{articles:C,basePath:a})]}),(!!r?.previousArticle||!!r?.nextArticle)&&jsxs("nav",{className:"article-nav mx-auto mt-12 max-w-4xl",children:[jsx(le,{className:"mb-8"}),jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[r?.previousArticle&&jsx(Ce,{className:"group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxs(ee,{href:r.previousArticle.url,className:"block",children:[r.previousArticle.featuredImage&&jsx(xt,{src:r.previousArticle.featuredImage,alt:r.previousArticle.featuredImageAlt??`Featured image for ${r.previousArticle.title}`}),jsxs(Le,{className:"p-4",children:[jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"\u2190 Previous Article"}),jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.previousArticle.title})]})]})}),r?.nextArticle&&jsx(Ce,{className:b("group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",!r?.previousArticle&&"md:col-start-2"),children:jsxs(ee,{href:r.nextArticle.url,className:"block",children:[r.nextArticle.featuredImage&&jsx(xt,{src:r.nextArticle.featuredImage,alt:r.nextArticle.featuredImageAlt??`Featured image for ${r.nextArticle.title}`}),jsxs(Le,{className:"p-4 md:text-right",children:[jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"Next Article \u2192"}),jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.nextArticle.title})]})]})})]})]}),(()=>{let H=se(at(e,{customDomain:e.site.domain,pathPrefix:a}));return jsx("script",{type:H.type,dangerouslySetInnerHTML:H.dangerouslySetInnerHTML})})()]})}function rr({author:e,size:t}){let r=t==="lg"?"h-12 w-12 text-base":"h-9 w-9 text-sm",n=oi(e.name);return e.avatarUrl?jsx(mt,{src:e.avatarUrl,alt:e.name,width:t==="lg"?48:36,height:t==="lg"?48:36,className:b("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsx("span",{className:b("bg-muted text-muted-foreground inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function ni({author:e}){let t=ii(e);return t.length===0?null:jsx("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:t.map(r=>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 ii(e){let t=e.socialLinks;return t?[t.website?{key:"website",href:t.website,label:"website",external:true,icon:jsx(Globe,{className:"size-4","aria-hidden":"true"})}:void 0,t.x?{key:"x",href:t.x,label:"on X",external:true,icon:jsx(FaXTwitter,{className:"size-4","aria-hidden":"true"})}:void 0,t.linkedin?{key:"linkedin",href:t.linkedin,label:"on LinkedIn",external:true,icon:jsx(FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}:void 0,t.github?{key:"github",href:t.github,label:"on GitHub",external:true,icon:jsx(FaGithub,{className:"size-4","aria-hidden":"true"})}:void 0,t.email?{key:"email",href:`mailto:${t.email}`,label:"email",external:false,icon:jsx(Mail,{className:"size-4","aria-hidden":"true"})}:void 0].filter(n=>!!n):[]}function oi(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function si({cta:e}){return jsx("div",{className:"rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] p-5 sm:p-6",children:jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[jsxs("div",{className:"space-y-1",children:[jsx("h2",{className:"text-foreground text-xl font-semibold",children:e.title}),e.description&&jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.description})]}),jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:flex-row",children:[e.primary&&jsxs(ee,{href:e.primary.href,className:"inline-flex 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.primary.label,jsx(ArrowUpRight,{className:"size-4","aria-hidden":"true"})]}),e.secondary&&jsxs(ee,{href:e.secondary.href,className:"border-border bg-background text-foreground hover:bg-muted inline-flex items-center justify-center gap-2 rounded-full border px-4 py-2 text-sm font-semibold transition-colors",children:[e.secondary.label,jsx(ArrowUpRight,{className:"size-4","aria-hidden":"true"})]})]})]})})}function ai({title:e,url:t}){let r=encodeURIComponent(e),n=encodeURIComponent(t);return jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2 sm:gap-3",children:[jsx(ze,{title:e,url:t,size:"sm"}),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:jsx(FaXTwitter,{className:"size-4","aria-hidden":"true"})}),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:jsx(FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}),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:jsx(Mail,{className:"size-4","aria-hidden":"true"})})]})}function li({articles:e,basePath:t}){return jsxs("section",{className:"space-y-4","aria-labelledby":"related-articles-title",children:[jsx("h2",{id:"related-articles-title",className:"text-xl font-semibold",children:"You might also like"}),jsx("div",{className:"grid gap-4 md:grid-cols-3",children:e.map(r=>jsxs(ee,{href:N(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&&jsx(xt,{src:r.featuredImage,alt:r.featuredImageAlt??`Featured image for ${r.title}`}),jsxs("div",{className:"p-4",children:[jsx("h3",{className:"text-foreground line-clamp-3 font-semibold transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.title}),r.excerpt&&jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:r.excerpt})]})]},r.id))})]})}function xt({src:e,alt:t}){return jsx("div",{className:"border-border aspect-[16/9] overflow-hidden border-b bg-[var(--blog-accent-bg)]",children:jsx(mt,{src:e,alt:t,width:480,height:270,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"})})}function ci(e,t="/blog"){let r=e.meta.title??e.title,n=e.meta.description??e.excerpt,o=e.meta.canonicalUrl??`${e.site.domain}${N(t,e.slug)}`,i=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:o,images:i?[{url:i,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:i?[i]:void 0},alternates:{canonical:o}}}function cr({author:e,articles:t,site:r,className:n,basePath:o="/blog",theme:i,pagination:s,navigation:c}){let l=E(o)||"/",u=c?.backToHome?.url??l,m=_(l,e.slug),a=s?.totalItems??t.length,f=se(He(e,{pathPrefix:l}));return jsxs("main",{style:j(i),className:b("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:[jsxs("header",{className:"mb-10 space-y-8 sm:mb-14",children:[jsxs(ee,{href:u,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:[jsx(ArrowLeft,{className:"size-4 transition-transform group-hover:-translate-x-1","aria-hidden":"true"}),c?.backToHome?.label??"Back to all articles"]}),jsxs("div",{className:"grid gap-6 sm:grid-cols-[auto_minmax(0,1fr)] sm:items-center",children:[jsx(bi,{author:e}),jsxs("div",{className:"min-w-0 space-y-4",children:[jsxs("div",{className:"space-y-2",children:[jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.isGuest&&jsx(Re,{variant:"outline",className:"text-xs",children:"Guest Author"})}),jsx("h1",{className:b("text-4xl leading-tight font-light text-balance sm:text-5xl",V),children:e.name})]}),e.bio&&jsx("p",{className:"text-muted-foreground max-w-3xl text-lg leading-relaxed text-pretty",children:e.bio}),jsx(gi,{author:e})]})]})]}),jsx(le,{className:"mb-8"}),jsxs("section",{"aria-labelledby":"author-articles-title",className:"space-y-6",children:[jsx("div",{className:"flex flex-wrap items-end justify-between gap-3",children:jsxs("div",{children:[jsxs("h2",{id:"author-articles-title",className:"text-foreground text-2xl font-semibold",children:["Articles by ",e.name]}),jsxs("p",{className:"text-muted-foreground mt-1 text-sm",children:[a," ",a===1?"article":"articles"," on ",r.name]})]})}),t.length===0?jsx("p",{className:"text-muted-foreground border-border rounded-2xl border p-6",children:"This author does not have any published articles yet."}):jsx("div",{className:"divide-border divide-y",children:t.map(h=>jsx(hi,{article:h,basePath:l},h.id))}),s&&s.totalPages>1&&jsx("div",{className:"pt-4",children:jsx(ge,{currentPage:s.currentPage,totalPages:s.totalPages,baseUrl:s.baseUrl??m,className:"justify-center"})})]}),jsx("script",{type:f.type,dangerouslySetInnerHTML:f.dangerouslySetInnerHTML})]})}function gi({author:e}){let t=fi(e);return t.length===0?null:jsx("div",{className:"flex flex-wrap items-center gap-2","aria-label":"Author links",children:t.map(r=>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 fi(e){let t=e.socialLinks;return t?[t.website?{href:t.website,label:"website",ariaLabel:`${e.name}'s website`,external:true,icon:jsx(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: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: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: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:jsx(Mail,{className:"size-4","aria-hidden":"true"})}:null].filter(r=>r!==null):[]}function hi({article:e,basePath:t}){let r=formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsx("article",{className:"py-6 first:pt-0 last:pb-0",children:jsxs(ee,{href:N(t,e.slug),className:"group grid gap-4 hover:no-underline sm:grid-cols-[minmax(0,1fr)_12rem] sm:items-start",children:[jsxs("div",{className:"min-w-0 space-y-3",children:[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&&jsx("p",{className:"text-muted-foreground line-clamp-3 leading-relaxed",children:e.excerpt}),jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[jsx("time",{dateTime:e.publishedAt,children:r}),jsx("span",{"aria-hidden":"true",children:"\u2022"}),jsxs("span",{children:[Math.ceil(e.readingSeconds/60)," min read"]})]})]}),e.featuredImage&&jsx("div",{className:"border-border relative aspect-[16/10] overflow-hidden rounded-xl border bg-[var(--blog-accent-bg)]",children:jsx(mt,{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 bi({author:e}){return e.avatarUrl?jsx(mt,{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}):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:xi(e.name)})}function xi(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function yi(e,t,r="/blog"){let n=`https://${t.domain.replace(/^https?:\/\//,"").replace(/\/+$/,"")}${_(r,e.slug)}`,o=`${e.name} - ${t.name}`,i=e.bio??`Read articles by ${e.name} on ${t.name}.`;return {title:o,description:i,authors:[{name:e.name}],openGraph:{title:o,description:i,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:o,description:i,images:e.avatarUrl?[e.avatarUrl]:void 0},alternates:{canonical:n}}}var Ve=class{articles=new Map;operations=new Map;metadata=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 i={success:false,error:{code:"PUB003",message:"This URL is already in use. Please choose another."},idempotencyKey:r};return await this.storeOperationResult(r,i),i}this.articles.set(t.slug,t);let o={success:true,url:`/${t.slug}`,platformPostId:t.id,publishedAt:t.publishedAt,idempotencyKey:r};return await this.storeOperationResult(r,o),o}async getArticle(t){return this.articles.get(t)??null}async listArticles(t={}){let{limit:r=10,offset:n=0,sortBy:o="publishedAt",order:i="desc"}=t,s=Array.from(this.articles.values());return s.sort((l,u)=>{let m=new Date(l[o]).getTime(),a=new Date(u[o]).getTime();return i==="desc"?a-m:m-a}),{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 i={success:false,error:{code:"PUB007",message:"Article not found"},idempotencyKey:r};return await this.storeOperationResult(r,i),i}this.articles.delete(t);let o={success:true,idempotencyKey:r};return await this.storeOperationResult(r,o),o}async checkIdempotency(t){return this.operations.get(t)??null}async storeOperationResult(t,r){this.operations.set(t,r);}async setMetadata(t,r){this.metadata.set(t,r);}async getMetadata(t){return this.metadata.has(t)?this.metadata.get(t):null}};function vi(){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 Pi(){let e=globalThis;e.__BLOG_PLATFORM_STORAGE__||(vi(),e.__BLOG_PLATFORM_STORAGE__=new Ve);let t=e.__BLOG_PLATFORM_STORAGE__;if(!t)throw new Error("Blog platform storage not initialized");return t}function M(){return Pi()}function vt(e){let t=globalThis;t.__BLOG_PLATFORM_STORAGE__=e;}function xe(e){let t=new Map;for(let r of e)r.author?.slug&&t.set(r.author.slug,dr(t.get(r.author.slug),r.author));return Array.from(t.values()).sort((r,n)=>r.name.localeCompare(n.name))}function ur(e,t){let r=t.filter(o=>o.author?.slug===e).sort((o,i)=>new Date(i.publishedAt).getTime()-new Date(o.publishedAt).getTime()),n=r.reduce((o,i)=>i.author?dr(o,i.author):o,null);return n?{author:n,articles:r}:null}async function Ai(e,t={},r=M()){let{articles:n}=await r.listArticles({limit:t.limit??1e3,offset:t.offset??0,sortBy:"publishedAt",order:"desc"});return ur(e,n)}function dr(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 wi(e){let t=e.topics??[];return t.find(r=>r.isPrimary)??t[0]??null}function ye(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 Pt(e,t){let r=e.filter(o=>(o.topics??[]).some(i=>i.slug===t));if(r.length===0)return null;let n=r.flatMap(o=>o.topics??[]).find(o=>o.slug===t)??null;return n?{topic:n,articles:r}:null}function Ti({articles:e,basePath:t="/blog",title:r="Topics",description:n="Browse articles by topic.",className:o,theme:i}){let s=E(t)||"/",c=ye(e);return jsxs("main",{style:j(i),className:b("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",o),children:[jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsx(ee,{href:s,className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all articles"}),jsx("h1",{className:b("text-4xl font-light tracking-tight text-balance sm:text-5xl",V),children:r}),jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),c.length===0?jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No topics have published articles yet."}):jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:c.map(l=>{let u=e.filter(m=>(m.topics??[]).some(a=>a.slug===l.slug)).length;return jsxs(ee,{href:N(s,`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:[jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold transition-colors",children:l.name}),l.description&&jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:l.description}),jsxs("p",{className:"text-muted-foreground mt-4 text-sm",children:[u," ",u===1?"article":"articles"]})]},l.slug)})})]})}function Ri({articles:e,topicSlug:t,basePath:r="/blog",className:n,theme:o}){let i=E(r)||"/",s=Pt(e,t);return jsxs("main",{style:j(o),className:b("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:[jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsx(ee,{href:N(i,"topics"),className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all topics"}),jsx("h1",{className:b("text-4xl font-light tracking-tight text-balance sm:text-5xl",V),children:s?.topic.name??"Topic not found"}),s?.topic.description&&jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:s.topic.description})]}),s?jsx("div",{className:"grid gap-5 md:grid-cols-2",children:s.articles.map(c=>jsx(Ci,{article:c,topic:s.topic,basePath:i},c.id))}):jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No published articles were found for this topic."})]})}function Ci({article:e,topic:t,basePath:r}){let n=N(r,e.slug),o=formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxs(ee,{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&&jsx("div",{className:"relative aspect-[16/9] overflow-hidden",children:jsx(mt,{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"})}),jsxs("div",{className:"space-y-3 p-5",children:[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}),jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold text-balance transition-colors",children:e.title}),e.excerpt&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:e.excerpt}),jsx("p",{className:"text-muted-foreground text-sm",children:o})]})]})}function ki({articles:e,basePath:t="/blog",title:r="Authors",description:n="Browse articles by author.",className:o,theme:i}){let s=E(t)||"/",c=xe(e);return jsxs("main",{style:j(i),className:b("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",o),children:[jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsx(ee,{href:s,className:"text-muted-foreground text-sm font-medium transition-colors hover:text-[var(--blog-accent)]",children:"Back to all articles"}),jsx("h1",{className:b("text-4xl font-light tracking-tight text-balance sm:text-5xl",V),children:r}),jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),c.length===0?jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No authors have published articles yet."}):jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:c.map(l=>{let u=e.filter(m=>m.author?.slug===l.slug).length;return jsx(ee,{href:_(s,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:jsxs("div",{className:"flex items-start gap-4",children:[jsx(_i,{author:l}),jsxs("div",{className:"min-w-0 space-y-2",children:[jsx("h2",{className:"text-xl font-semibold transition-colors group-hover:text-[var(--blog-accent)]",children:l.name}),l.bio&&jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:l.bio}),jsxs("p",{className:"text-muted-foreground text-sm",children:[u," ",u===1?"article":"articles"]})]})]})},l.slug)})})]})}function _i({author:e}){let t=Ii(e.name);return e.avatarUrl?jsx(mt,{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"}):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 Ii(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function F(e){return `sha256:${createHash("sha256").update(e).digest("hex")}`}function At(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 i=/^Token\s+(.+)$/i.exec(t);return i?.[1]?i[1]:null}var Xe=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=>At(t);hashToken(t){return F(t)}},ve=class extends Xe{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(o=>o.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"}},We=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 Ei(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??=new We,globalThis.__BLOG_PLATFORM_AUTH_CONFIG__}function Ke(e){globalThis.__BLOG_PLATFORM_AUTH_CONFIG__=e;}function wt(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??Ei()}function Oi(e){Ke(new ve(e));}async function W(e){let t=wt(),r=t.extractToken?t.extractToken(e):At(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 Mi(e,t=""){let n=wt().errorMessages??{},o,i;switch(e.errorCode){case "missing":o=n.missing??"Authentication token is required",i="PUB005";break;case "expired":o=n.expired??"Authentication token has expired",i="PUB005";break;default:o=n.invalid??"Invalid authentication credentials",i="PUB005";break}return {success:false,error:{code:i,message:o,details:{authError:e.errorCode??"invalid"}},idempotencyKey:t}}async function Q(e){let t=await W(e);return t.authenticated?{authenticated:true,context:t.result.context}:{authenticated:false,error:Mi(t.result)}}function $i(){let e=process.env.SKIP_BLOG_PLATFORM_AUTH;return e==="true"||e==="1"||process.env.NODE_ENV==="test"}function Ui(){return globalThis.__BLOG_PLATFORM_RATE_LIMITER__??null}function Hi(e){let t=globalThis;t.__BLOG_PLATFORM_RATE_LIMITER__=e;}function Je(e){let{redisUrl:t,redisToken:r,requestsPerMinute:n=5,keyPrefix:o="blog-platform-ratelimit",analytics:i=true}=e,s=new Redis({url:t,token:r}),c=new Ratelimit({redis:s,analytics:i,prefix:o,limiter:Ratelimit.slidingWindow(n,"1m")});Hi(c);}function St(){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}Je({redisUrl:e,redisToken:t}),console.log("Blog platform: Rate limiting configured (5 requests per minute per token)");}async function gr(e){let t=Ui();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 fr(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 K(e,t=""){let r=await gr(e);return r.success?{allowed:true,rateLimitResult:r}:{allowed:false,errorResponse:fr(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 Ye(e){let{auth:t,storage:r,rateLimit:n,autoRateLimit:o=true}=e;if(!t)throw new Error(`Blog platform initialization failed: 'auth' is required.
|
|
40
40
|
Example: initBlogPlatform({ auth: new EnvAuth() })
|
|
41
|
-
See https://github.com/xexr/blog-platform#authentication for more details.`);console.log("Blog platform: Setting up authentication"),
|
|
41
|
+
See https://github.com/xexr/blog-platform#authentication for more details.`);console.log("Blog platform: Setting up authentication"),Ke(t),n?(console.log("Blog platform: Using custom rate limiting configuration"),Je(n)):o?(console.log("Blog platform: Auto-configuring rate limiting from environment"),St()):console.log("Blog platform: Rate limiting disabled"),r?(console.log("Blog platform: Using custom storage provider"),vt(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 ji(e){if(globalThis.__BLOG_PLATFORM_INITIALISED__){console.log("Blog platform: Already initialized, skipping");return}console.log("Blog platform: Initializing blog platform once"),Ye(e);}function Fi(){Ye({auth:new Be,autoRateLimit:false}),console.log("Blog platform: Development mode enabled (no auth, in-memory storage, no rate limiting)");}function Gi(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.`);Ye({auth:new ve(t),autoRateLimit:true}),console.log("Blog platform: Production mode enabled (environment-based auth, rate limiting)");}var T=sqliteTable("bp_articles",{id:text("id").primaryKey(),slug:text("slug").notNull(),title:text("title").notNull(),excerpt:text("excerpt").notNull(),content:text("content").notNull(),readingSeconds:integer("reading_seconds").notNull(),wordCount:integer("word_count").notNull(),publishedAt:text("published_at").notNull(),updatedAt:text("updated_at").notNull(),featuredImage:text("featured_image"),featuredImageAlt:text("featured_image_alt"),featuredImageCaption:text("featured_image_caption"),featuredImageCreditText:text("featured_image_credit_text"),featuredImageCreditUrl:text("featured_image_credit_url"),authorJson:text("author_json"),siteJson:text("site_json").notNull(),metaJson:text("meta_json").notNull(),version:integer("version").notNull()},e=>({slugUniqueIdx:uniqueIndex("bp_articles_slug_unique").on(e.slug)})),ue=sqliteTable("bp_operations",{key:text("key").primaryKey(),resultJson:text("result_json").notNull(),createdAt:integer("created_at",{mode:"timestamp_ms"}).notNull(),expiresAt:integer("expires_at",{mode:"timestamp_ms"})}),ne=sqliteTable("bp_metadata",{key:text("key").primaryKey(),valueJson:text("value_json").notNull(),updatedAt:integer("updated_at",{mode:"timestamp_ms"}).notNull()}),kt=2,Ee=["bp_articles","bp_operations","bp_metadata"],Xi={bpArticles:T,bpOperations:ue,bpMetadata:ne};function Wi(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,featuredImageCaption:e.featuredImageCaption??null,featuredImageCreditText:e.featuredImageCreditText??null,featuredImageCreditUrl:e.featuredImageCreditUrl??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 hr(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,featuredImageCaption:e.featuredImageCaption??void 0,featuredImageCreditText:e.featuredImageCreditText??void 0,featuredImageCreditUrl:e.featuredImageCreditUrl??void 0,author:e.authorJson?JSON.parse(e.authorJson):null,site:JSON.parse(e.siteJson),topics:Ki(e.metaJson),meta:Ji(e.metaJson),version:e.version}}function Ki(e){return JSON.parse(e).__bloggyTopics??[]}function Ji(e){let t=JSON.parse(e);return delete t.__bloggyTopics,t}var Oe=class extends Error{code="BLOG_PLATFORM_SCHEMA_MISSING";missingTables;setupSql;constructor(t,r={}){super(`Blog platform database schema is missing required table(s): ${t.join(", ")}. Run the @xexr/blog-platform schema migration/setup for the current package version.`),this.name="BlogPlatformSchemaError",this.missingTables=t,this.setupSql=t.map(vr),r.cause!==void 0&&(this.cause=r.cause);}},Nt=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:T.id}).from(T).where(eq(T.id,t.id)).limit(1)).length!==0)return n}else return n;let o=await this.db.select().from(T).where(eq(T.slug,t.slug)).limit(1),i=o[0];if(i&&i.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 s=Wi(t);o.length===0?await this.db.insert(T).values(s).run():await this.db.update(T).set({title:s.title,excerpt:s.excerpt,content:s.content,readingSeconds:s.readingSeconds,wordCount:s.wordCount,updatedAt:s.updatedAt,featuredImage:s.featuredImage,featuredImageAlt:s.featuredImageAlt,featuredImageCaption:s.featuredImageCaption,featuredImageCreditText:s.featuredImageCreditText,featuredImageCreditUrl:s.featuredImageCreditUrl,authorJson:s.authorJson,siteJson:s.siteJson,metaJson:s.metaJson,version:s.version}).where(and(eq(T.id,s.id),eq(T.slug,s.slug))).run();let c={success:true,url:`/${t.slug}`,platformPostId:t.id,publishedAt:t.publishedAt,idempotencyKey:r};return await this.storeOperationResult(r,c),c}async getArticle(t){let r=await this.db.select().from(T).where(eq(T.slug,t)).limit(1);return r[0]?hr(r[0]):null}async listArticles(t={}){let{limit:r=10,offset:n=0,sortBy:o="publishedAt",order:i="desc"}=t,s=o==="publishedAt"?T.publishedAt:T.updatedAt,c=i==="desc"?desc(s):s,l=await this.db.select().from(T).orderBy(c).limit(r).offset(n),u=await this.db.select({c:sql`count(*)`}).from(T),m=Number(u?.[0]?.c??0);return {articles:l.map(hr),total:m}}async removeArticle(t,r){let n=await this.checkIdempotency(r);if(n)if(n.success){if(!((await this.db.select({id:T.id}).from(T).where(eq(T.slug,t)).limit(1)).length>0))return n}else return n;if(!(await this.db.select().from(T).where(eq(T.slug,t)).limit(1))[0]){let s={success:false,error:{code:"PUB007",message:"Article not found"},idempotencyKey:r};return await this.storeOperationResult(r,s),s}await this.db.delete(T).where(eq(T.slug,t)).run();let i={success:true,idempotencyKey:r};return await this.storeOperationResult(r,i),i}async checkIdempotency(t){let r=await this.db.select().from(ue).where(eq(ue.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(),o=this.options.operationTtlMs?n+this.options.operationTtlMs:null;await this.db.delete(ue).where(eq(ue.key,t)).run(),await this.db.insert(ue).values({key:t,resultJson:JSON.stringify(r),createdAt:new Date(n),expiresAt:o?new Date(o):null}).run();}async setMetadata(t,r){let n=new Date;try{await this.db.delete(ne).where(eq(ne.key,t)).run(),await this.db.insert(ne).values({key:t,valueJson:JSON.stringify(r),updatedAt:n}).run();}catch(o){br(o,"bp_metadata");}}async getMetadata(t){let r;try{r=await this.db.select({valueJson:ne.valueJson}).from(ne).where(eq(ne.key,t)).limit(1);}catch(o){br(o,"bp_metadata");}let n=r[0];if(!n)return null;try{return JSON.parse(n.valueJson)}catch{return null}}};async function yr(e){let t=await e.all(sql`
|
|
42
|
+
SELECT name
|
|
43
|
+
FROM sqlite_master
|
|
44
|
+
WHERE type = 'table'
|
|
45
|
+
`),r=new Set(t.map(i=>i.name)),n=Ee.filter(i=>r.has(i)),o=Ee.filter(i=>!r.has(i));return {ok:o.length===0,schemaVersion:kt,requiredTables:Ee,presentTables:n,missingTables:o,setupSql:o.map(vr)}}async function Yi(e){let t=await yr(e);if(!t.ok)throw new Oe(t.missingTables)}var Tt=`CREATE TABLE IF NOT EXISTS bp_articles (
|
|
42
46
|
id TEXT PRIMARY KEY,
|
|
43
47
|
slug TEXT NOT NULL UNIQUE,
|
|
44
48
|
title TEXT NOT NULL,
|
|
@@ -57,16 +61,20 @@ See https://github.com/xexr/blog-platform#authentication for more details.`);con
|
|
|
57
61
|
site_json TEXT NOT NULL,
|
|
58
62
|
meta_json TEXT NOT NULL,
|
|
59
63
|
version INTEGER NOT NULL
|
|
60
|
-
);`,
|
|
64
|
+
);`,Rt=`CREATE TABLE IF NOT EXISTS bp_operations (
|
|
61
65
|
key TEXT PRIMARY KEY,
|
|
62
66
|
result_json TEXT NOT NULL,
|
|
63
67
|
created_at INTEGER NOT NULL,
|
|
64
68
|
expires_at INTEGER
|
|
65
|
-
)
|
|
66
|
-
|
|
69
|
+
);`,Ct=`CREATE TABLE IF NOT EXISTS bp_metadata (
|
|
70
|
+
key TEXT PRIMARY KEY,
|
|
71
|
+
value_json TEXT NOT NULL,
|
|
72
|
+
updated_at INTEGER NOT NULL
|
|
73
|
+
);`;function vr(e){switch(e){case "bp_articles":return Tt;case "bp_operations":return Rt;case "bp_metadata":return Ct}}function br(e,t){throw Qi(e,t)?new Oe([t],{cause:e}):e}function Qi(e,t){return Pr(e).some(r=>r.includes(`no such table: ${t}`)||r.includes(`no such table: main.${t}`))}function Pr(e){if(!e||typeof e!="object")return [String(e)];let t=[];e instanceof Error&&t.push(e.message);let r=e.cause;return r!==void 0&&t.push(...Pr(r)),t}function Zi(){return {schemaVersion:kt,requiredTableNames:Ee,createAll:[Tt,Rt,Ct],createArticles:Tt,createOperations:Rt,createMetadata:Ct}}function Ae(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 Ar(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 de(e,t={}){let{forceHttps:r=true,removeTrailingSlash:n=true,domain:o=e.site.domain,pathPrefix:i="/blog"}=t;if(!o)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 s=Ae(o,r),c=Ar(e.slug),l=i.replace(/^(?!\/)/,"/").replace(/\/+$/,""),u=`${s}${l}/${c}`;return n&&(u=u.replace(/\/+$/,"")),u}function eo(e,t,r={}){return de({slug:t,site:e},r)}function to(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 ro(e){try{let t=new URL(e);return `${t.protocol}//${t.host}`}catch{throw new Error("Invalid canonical URL provided")}}function no(e,t={}){let r=de(e,t);return {...e,meta:{...e.meta,canonicalUrl:r}}}function io(e,t={},r){let n=r?.path??"/blog",i=`https://${t.canonical?.domain??e.domain}${n}`,s=r?.title?`${r.title} | ${e.name}`:e.name,c=r?.description??e.description,l=t.openGraph?.siteName??e.name,u=[{name:"description",content:c},{name:"author",content:l}];r?.pageNumber&&r.pageNumber>1&&u.push({name:"page",content:r.pageNumber.toString()}),t.meta?.robots&&u.push({name:"robots",content:t.meta.robots}),t.meta?.viewport&&u.push({name:"viewport",content:t.meta.viewport}),t.meta?.themeColor&&u.push({name:"theme-color",content:t.meta.themeColor}),t.meta?.applicationName&&u.push({name:"application-name",content:t.meta.applicationName});let m=[{property:"og:title",content:s},{property:"og:description",content:c},{property:"og:url",content:i},{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&&m.push({property:"og:image",content:t.openGraph.defaultImage},{property:"og:image:alt",content:`${l} - ${e.tagline}`});let a=oo(null,{site:t.twitter?.site,creator:t.twitter?.creator,cardType:t.twitter?.cardType??"summary"},{title:s,description:c,image:t.openGraph?.defaultImage});return {meta:u,openGraph:m,twitter:a,links:[{rel:"canonical",href:i}],title:s,description:c,canonicalUrl:i}}function oo(e,t,r){let n=r?.title??e?.meta.title??e?.title??"",o=r?.description??e?.meta.description??e?.excerpt??"",i=r?.image??e?.meta.ogImage??e?.featuredImage,s=[{name:"twitter:card",content:t.cardType},{name:"twitter:title",content:n},{name:"twitter:description",content:o}];return t.site&&s.push({name:"twitter:site",content:t.site}),t.creator&&s.push({name:"twitter:creator",content:t.creator}),i&&(s.push({name:"twitter:image",content:i}),e?.featuredImageAlt),s}function so(e){let t=[];return t.push(`<title>${U(e.title)}</title>`),e.meta.forEach(r=>{let n=[];r.name&&n.push(`name="${U(r.name)}"`),r.property&&n.push(`property="${U(r.property)}"`),r.httpEquiv&&n.push(`http-equiv="${U(r.httpEquiv)}"`),n.push(`content="${U(r.content)}"`),t.push(`<meta ${n.join(" ")} />`);}),e.openGraph.forEach(r=>{t.push(`<meta property="${U(r.property)}" content="${U(r.content)}" />`);}),e.twitter.forEach(r=>{t.push(`<meta name="${U(r.name)}" content="${U(r.content)}" />`);}),e.links.forEach(r=>{let n=[];n.push(`rel="${U(r.rel)}"`),n.push(`href="${U(r.href)}"`),r.type&&n.push(`type="${U(r.type)}"`),r.title&&n.push(`title="${U(r.title)}"`),t.push(`<link ${n.join(" ")} />`);}),t.join(`
|
|
74
|
+
`)}function U(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function ao(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(i=>i.property==="og:image")||r.push("OpenGraph image missing - social media sharing will not show image preview"),e.twitter.find(i=>i.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 _t(e,t,r=[],n={}){let{includeAuthorPages:o=true,includeTopicPages:i=true,includePaginationPages:s=true,articlesPerPage:c=10,maxEntries:l=5e4,changeFrequency:u={},priority:m={}}=n,a=[],f=Ae(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true),h=n.canonical?.pathPrefix??"/blog",g=r.length>0?r:xe(t),p=ye([...t]);if(a.push({url:`${f}${h}`,lastModified:z(t),changeFrequency:u.homePage??"daily",priority:m.homePage??1}),t.forEach(x=>{if(a.length>=l)return;let S=de(x,n.canonical);a.push({url:S,lastModified:x.updatedAt,changeFrequency:u.articles??"monthly",priority:m.articles??.8});}),i&&p.length>0&&(a.length<l&&a.push({url:`${f}${N(h,"topics")}`,lastModified:z(t),changeFrequency:u.topicPages??"weekly",priority:m.topicPages??.6}),p.forEach(x=>{if(a.length>=l)return;let S=t.filter($=>($.topics??[]).some(A=>A.slug===x.slug));a.push({url:`${f}${N(h,`topics/${x.slug}`)}`,lastModified:z(S),changeFrequency:u.topicPages??"weekly",priority:m.topicPages??.6});})),o&&g.length>0&&(a.length<l&&a.push({url:`${f}${N(h,"authors")}`,lastModified:z(t),changeFrequency:u.authorPages??"weekly",priority:m.authorPages??.6}),g.forEach(x=>{if(a.length>=l)return;let S=`${f}${_(h,x.slug)}`,$=t.filter(C=>C.author?.id===x.id),A=z($);a.push({url:S,lastModified:A,changeFrequency:u.authorPages??"weekly",priority:m.authorPages??.6});})),s&&t.length>c){let x=Math.ceil(t.length/c);for(let S=2;S<=x&&!(a.length>=l);S++)a.push({url:`${f}${h}?page=${S}`,lastModified:z(t),changeFrequency:u.paginationPages??"daily",priority:m.paginationPages??.5});}return a}function lo(e,t,r=[],n={}){let{includeAuthorPages:o=true,includeTopicPages:i=true,includePaginationPages:s=true,articlesPerPage:c=10,maxEntries:l=5e4,changeFrequency:u={},priority:m={}}=n,a=[],f=Ae(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true),h=n.canonical?.pathPrefix??"/blog",g=new Date().toISOString(),p=r.length>0?r:xe(t),x=ye([...t]),S=1;if(S+=t.length,i&&x.length>0&&(S+=x.length+1),o&&(S+=p.length>0?p.length+1:0),s&&t.length>c){let A=Math.ceil(t.length/c);S+=A-1;}let $=S>l;if(a.push({loc:`${f}${h}`,lastmod:z(t),changefreq:u.homePage??"daily",priority:m.homePage??1}),t.forEach(A=>{if(a.length>=l)return;let C=de(A,n.canonical);a.push({loc:C,lastmod:A.updatedAt,changefreq:u.articles??"monthly",priority:m.articles??.8});}),i&&x.length>0&&(a.length<l&&a.push({loc:`${f}${N(h,"topics")}`,lastmod:z(t),changefreq:u.topicPages??"weekly",priority:m.topicPages??.6}),x.forEach(A=>{if(a.length>=l)return;let C=t.filter(H=>(H.topics??[]).some(pe=>pe.slug===A.slug));a.push({loc:`${f}${N(h,`topics/${A.slug}`)}`,lastmod:z(C),changefreq:u.topicPages??"weekly",priority:m.topicPages??.6});})),o&&p.length>0&&(a.length<l&&a.push({loc:`${f}${N(h,"authors")}`,lastmod:z(t),changefreq:u.authorPages??"weekly",priority:m.authorPages??.6}),p.forEach(A=>{if(a.length>=l)return;let C=`${f}${_(h,A.slug)}`,H=t.filter(Ze=>Ze.author?.id===A.id),pe=z(H);a.push({loc:C,lastmod:pe,changefreq:u.authorPages??"weekly",priority:m.authorPages??.6});})),s&&t.length>c){let A=Math.ceil(t.length/c);for(let C=2;C<=A&&!(a.length>=l);C++)a.push({loc:`${f}${h}?page=${C}`,lastmod:z(t),changefreq:u.paginationPages??"daily",priority:m.paginationPages??.5});}return {entries:a,totalEntries:a.length,truncated:$,generatedAt:g,baseUrl:f}}function wr(e){let t='<?xml version="1.0" encoding="UTF-8"?>',r='<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',n="</urlset>",o=e.entries.map(i=>{let s=[];return s.push(" <url>"),s.push(` <loc>${Me(i.loc)}</loc>`),i.lastmod&&s.push(` <lastmod>${Me(i.lastmod)}</lastmod>`),i.changefreq&&s.push(` <changefreq>${Me(i.changefreq)}</changefreq>`),i.priority!==void 0&&s.push(` <priority>${i.priority.toFixed(1)}</priority>`),s.push(" </url>"),s.join(`
|
|
67
75
|
`)});return [t,r,...o,n].join(`
|
|
68
|
-
`)}function
|
|
76
|
+
`)}function co(e,t){let r='<?xml version="1.0" encoding="UTF-8"?>',n='<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',o="</sitemapindex>",i=e.map(s=>{let c=[];return c.push(" <sitemap>"),c.push(` <loc>${Me(s.url)}</loc>`),s.lastmod&&c.push(` <lastmod>${Me(s.lastmod)}</lastmod>`),c.push(" </sitemap>"),c.join(`
|
|
69
77
|
`)});return [r,n,...i,o].join(`
|
|
70
|
-
`)}function Fi(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((o,i)=>{try{new URL(o.loc);}catch{t.push(`Invalid URL at entry ${i+1}: ${o.loc}`);}o.priority!==void 0&&(o.priority<0||o.priority>1)&&t.push(`Invalid priority at entry ${i+1}: must be between 0.0 and 1.0`),o.lastmod&&!zi(o.lastmod)&&t.push(`Invalid lastmod date at entry ${i+1}: ${o.lastmod}`),o.loc.length>2048&&r.push(`URL at entry ${i+1} exceeds 2048 character limit`);});let n=new Map;return e.entries.forEach(o=>{let i=n.get(o.loc)??0;n.set(o.loc,i+1);}),n.forEach((o,i)=>{o>1&&t.push(`Duplicate URL found: ${i} (appears ${o} times)`);}),{valid:t.length===0,errors:t,warnings:r}}function F(e){return e.length===0?new Date().toISOString():e.reduce((r,n)=>{let o=new Date(n.updatedAt);return o>r?o:r},new Date(e[0].updatedAt)).toISOString()}function Gi(e,t,r=[],n={}){return async function(){let a=(await At(e,t,r,n)).map(u=>({loc:u.url,lastmod:typeof u.lastModified=="string"?u.lastModified:u.lastModified?.toISOString(),changefreq:u.changeFrequency,priority:u.priority})),c={entries:a,totalEntries:a.length,generatedAt:new Date().toISOString(),baseUrl:xe(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true)},l=cr(c);return new Response(l,{headers:{"Content-Type":"application/xml","Cache-Control":"public, max-age=3600, s-maxage=3600"}})}}function ji(e){return async function(){let r=[...e.staticRoutes??[],...e.getStaticRoutes?await e.getStaticRoutes():[]],n=await e.getSite(),o=await e.getArticles(),i=e.getAuthors?await e.getAuthors():[];return [...r,...await At(n,o,i,e.options)]}}function _e(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function zi(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 ye={name:"@xexr/blog-platform",version:"1.0.16"};function ur(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),o=parseInt(r[1]??"0",10),i=parseInt(r[2]?.split("-")[0]??"0",10);if(isNaN(n)||isNaN(o)||isNaN(i))throw new Error(`Invalid version format: ${e}`);return {major:n,minor:o,patch:i}}function V(){let e=ur(ye.version);return {name:ye.name,version:ye.version,...e}}function ne(e){try{let t=e.split(" "),r={};for(let n of t){let[o,i]=n.split("/");if(!o||!i)continue;let a=ur(i),c={name:o,version:i,...a};o==="bloggy"?r.bloggyVersion=c:o==="platform"&&(r.platformVersion=c);}return r}catch{return null}}function dr(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 mr={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 qi(){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 {...mr,enableCSP:!e,frameOptions:t??mr.frameOptions,enableHSTS:!r}}function Xi(e){return Object.entries(e).map(([t,r])=>r?`${t} ${r}`:t).join("; ")}function Wi(e){return Object.entries(e).map(([t,r])=>`${t}=${r}`).join(", ")}function Ki(e,t={}){let r={...qi(),...t},n={};if(r.enableCSP){let o={...r.cspDirectives,...t.cspDirectives??{}};n["Content-Security-Policy"]=Xi(o);}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&&Ji(e)){let o=[`max-age=${r.hstsMaxAge}`,r.hstsIncludeSubdomains?"includeSubDomains":""].filter(Boolean).join("; ");n["Strict-Transport-Security"]=o;}if(r.enablePermissionsPolicy){let o={...r.permissionsPolicyDirectives,...t.permissionsPolicyDirectives??{}};n["Permissions-Policy"]=Wi(o);}return n}function Ji(e){return !!(e.url.startsWith("https://")||e.headers.get("x-forwarded-proto")==="https"||e.headers.get("cf-visitor")?.includes('"scheme":"https"'))}function We(e,t={}){return Ki(e,{...t,cspDirectives:{...{"default-src":"'none'","frame-ancestors":"'none'","base-uri":"'none'"},...t.cspDirectives??{}}})}var pr={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 gr(){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 {...pr,allowedOrigins:e?e.split(",").map(n=>n.trim()):pr.allowedOrigins,allowWildcard:t,allowCredentials:r}}function fr(e,t){return e?t.allowWildcard?true:t.allowedOrigins.includes(e):false}function hr(e,t){let r=e.headers.get("origin"),n={};return t.allowWildcard?n["Access-Control-Allow-Origin"]="*":r&&fr(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 Yi(e,t,r,n){return {...hr(e,t),"Access-Control-Allow-Methods":r.join(", "),"Access-Control-Allow-Headers":n.join(", "),"Access-Control-Max-Age":t.maxAge.toString()}}var Qi=["Content-Type","X-Bloggy-Version","X-Idempotency-Key","Authorization","X-Requested-With"];function A(e,t,r={}){let{status:n=200,headers:o={},corsConfig:i={}}=r,a={...gr(),...i},c=hr(e,a),l=We(e,a.securityConfig),u={"Content-Type":"application/json",...c,...l,...o};return NextResponse.json(t,{status:n,headers:u})}function Ie(e,t,r={}){let{allowedHeaders:n=Qi,corsConfig:o={}}=r,i={...gr(),...o},a=e.headers.get("origin");if(a&&!i.allowWildcard&&!fr(a,i)){let u=We(e,i.securityConfig);return new NextResponse(null,{status:403,headers:{"Content-Type":"text/plain",...u}})}let c=Yi(e,i,[...t,"OPTIONS"],n),l=We(e,i.securityConfig);return new NextResponse(null,{status:200,headers:{...c,...l}})}async function Zi(e){try{let t=await Z(e);if(!t.authenticated){let p=await re(e);return A(e,p.error,{status:401})}let r=W(t.token??"anonymous"),n=await ee(r);if(!n.allowed){let p=n.errorResponse.error?.details?.rateLimit,x=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},S=$(x);return A(e,n.errorResponse,{status:429,headers:S})}if(!e.headers.get("content-type")?.includes("application/json"))return A(e,{success:!1,error:{code:"PUB001",message:"Content-Type must be application/json"},idempotencyKey:""},{status:400});let i;try{i=await e.json();}catch{return A(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let a=eo(i);if(a.length>0)return A(e,{success:!1,error:{code:"PUB001",message:"Missing required fields",details:{errors:a}},idempotencyKey:i.idempotencyKey??""},{status:400});let c=e.headers.get("X-Bloggy-Version");if(c){let p=ne(c);if(p?.platformVersion){let x=V();if(p.platformVersion.major!==x.major)return A(e,{success:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:p.platformVersion.version,serverVersion:x.version}},idempotencyKey:i.idempotencyKey},{status:409})}}if(i.dryRun){let p=[];return i.article.wordCount<50&&p.push("Article has fewer than 50 words, which may affect SEO"),(!i.article.excerpt||i.article.excerpt.length<120)&&p.push("Article excerpt is shorter than recommended 120 characters"),i.article.meta.keywords.length||p.push("No SEO keywords provided"),A(e,{success:!0,warnings:p,idempotencyKey:i.idempotencyKey},{status:200})}let l={...i.article,slug:i.slug??i.article.slug,meta:{...i.article.meta,description:i.metaDescription??i.article.meta.description}};if(!St(l.slug))return A(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:i.idempotencyKey},{status:400});let m=await X().saveArticle(l,i.idempotencyKey),s=V(),f=$(n.rateLimitResult),h={"X-Bloggy-Version":`platform/${s.version}`,"X-Idempotency-Key":i.idempotencyKey,...f};m.success&&(h.Location=m.url??`/${l.slug}`);let g=m.success?201:m.error?.code==="PUB003"?409:400;return A(e,m,{status:g,headers:h})}catch(t){return console.error("Publish endpoint error:",t),A(e,{success:false,error:{code:"PUB007",message:"Internal server error during publishing"},idempotencyKey:""},{status:500})}}function eo(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,o=["id","slug","title","content","publishedAt","site"];for(let i of o)n[i]||t.push(`Missing required article field: ${i}`);if(n.site&&typeof n.site=="object"){let i=n.site,a=["id","name","domain"];for(let c of a)i[c]||t.push(`Missing required site field: ${c}`);}if(n.meta&&typeof n.meta=="object"){let i=n.meta;Array.isArray(i.keywords)||t.push("Article meta.keywords must be an array");}}return t}function St(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function ro(e){try{let t=await Z(e);if(!t.authenticated){let g=await re(e);return NextResponse.json(g.error,{status:401})}let r=W(t.token??"anonymous"),n=await ee(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},x=$(p);return A(e,n.errorResponse,{status:429,headers:x})}if(!e.headers.get("content-type")?.includes("application/json"))return A(e,{success:!1,error:{code:"PUB001",message:"Content-Type must be application/json"},idempotencyKey:""},{status:400});let i;try{i=await e.json();}catch{return A(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let a=no(i);if(a.length>0)return A(e,{success:!1,error:{code:"PUB001",message:"Missing required fields",details:{errors:a}},idempotencyKey:i.idempotencyKey??""},{status:400});let c=e.headers.get("X-Bloggy-Version");if(c){let g=ne(c);if(g?.platformVersion){let p=V();if(g.platformVersion.major!==p.major)return A(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:i.idempotencyKey},{status:409})}}if(!io(i.slug))return A(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:i.idempotencyKey},{status:400});if(i.dryRun){let p=await X().getArticle(i.slug),x=[];return p||x.push("Article with this slug does not exist"),A(e,{success:!0,warnings:x,idempotencyKey:i.idempotencyKey},{status:200})}let u=await X().removeArticle(i.slug,i.idempotencyKey),m=V(),s=$(n.rateLimitResult),f={"X-Bloggy-Version":`platform/${m.version}`,"X-Idempotency-Key":i.idempotencyKey,...s},h=u.success?200:u.error?.code==="PUB007"?404:400;return A(e,u,{status:h,headers:f})}catch(t){return console.error("Unpublish endpoint error:",t),A(e,{success:false,error:{code:"PUB007",message:"Internal server error during unpublishing"},idempotencyKey:""},{status:500})}}function no(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 io(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function oo(e){try{let t=await Z(e);if(!t.authenticated){let s=await re(e),f={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:s.error?.error?.message??"Authentication required"}};return A(e,f,{status:401})}let r=W(t.token??"anonymous"),n=await ee(r);if(!n.allowed){let s=n.errorResponse.error?.details?.rateLimit,f=s&&typeof s=="object"&&"limit"in s&&"remaining"in s&&"reset"in s&&"count"in s&&"success"in s?s:{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},h=$(f),g={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 A(e,g,{status:429,headers:h})}let o=V(),i=e.headers.get("X-Bloggy-Version"),a={name:"unknown",version:"unknown",major:0,minor:0,patch:0};if(i)try{if(/^\d+\.\d+\.\d+/.test(i)){let s=i.split("."),f=parseInt(s[0]??"0",10),h=parseInt(s[1]??"0",10),g=parseInt(s[2]?.split("-")[0]??"0",10);a={name:"bloggy",version:i,major:f,minor:h,patch:g};}else {let s=ne(i);s?.bloggyVersion&&(a=s.bloggyVersion);}}catch(s){console.warn("Failed to parse X-Bloggy-Version header:",s);}let c={compatible:!0};a.version!=="unknown"&&(c=dr(a,o));let l={success:!0,versions:{bloggy:a,platform:o},compatibility:c},u=$(n.rateLimitResult),m={"X-Bloggy-Version":`platform/${o.version}`,"Cache-Control":"public, max-age=300, stale-while-revalidate=60",...u};return A(e,l,{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 A(e,r,{status:500})}}async function so(e,{params:t}){try{let{slug:r}=await t,n=await Z(e);if(!n.authenticated){let p=await re(e);return NextResponse.json(p.error,{status:401})}let o=W(n.token??"anonymous"),i=await ee(o);if(!i.allowed){let p=i.errorResponse.error?.details?.rateLimit||{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},x=$(p);return A(e,i.errorResponse,{status:429,headers:x})}if(!r||!St(r))return A(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 p=ne(a);if(p?.platformVersion){let x=V();if(p.platformVersion.major!==x.major)return A(e,{exists:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:p.platformVersion.version,serverVersion:x.version}}},{status:409})}}let u=await X().getArticle(r)!==null,m={exists:u,...u&&{message:"Slug is already in use. Please choose another (e.g., append '-v2')."}},s=V(),f=$(i.rateLimitResult),h={"X-Bloggy-Version":`platform/${s.version}`,...f},g=e.headers.get("X-Idempotency-Key");return g&&(h["X-Idempotency-Key"]=g,console.log(`Slug check for idempotency: ${g}, exists: ${u}`)),A(e,m,{status:200,headers:h})}catch(r){return console.error("Slug existence check error:",r instanceof Error?r.message:String(r)),A(e,{exists:false,error:{code:"PUB007",message:"Internal server error during slug check"}},{status:500})}}async function lo(e){return Ie(e,["GET"])}var Pl=ye.version;
|
|
71
|
-
export{
|
|
78
|
+
`)}function uo(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((o,i)=>{try{new URL(o.loc);}catch{t.push(`Invalid URL at entry ${i+1}: ${o.loc}`);}o.priority!==void 0&&(o.priority<0||o.priority>1)&&t.push(`Invalid priority at entry ${i+1}: must be between 0.0 and 1.0`),o.lastmod&&!go(o.lastmod)&&t.push(`Invalid lastmod date at entry ${i+1}: ${o.lastmod}`),o.loc.length>2048&&r.push(`URL at entry ${i+1} exceeds 2048 character limit`);});let n=new Map;return e.entries.forEach(o=>{let i=n.get(o.loc)??0;n.set(o.loc,i+1);}),n.forEach((o,i)=>{o>1&&t.push(`Duplicate URL found: ${i} (appears ${o} times)`);}),{valid:t.length===0,errors:t,warnings:r}}function z(e){return e.length===0?new Date().toISOString():e.reduce((r,n)=>{let o=new Date(n.updatedAt);return o>r?o:r},new Date(e[0].updatedAt)).toISOString()}function mo(e,t,r=[],n={}){return async function(){let s=(await _t(e,t,r,n)).map(u=>({loc:u.url,lastmod:typeof u.lastModified=="string"?u.lastModified:u.lastModified?.toISOString(),changefreq:u.changeFrequency,priority:u.priority})),c={entries:s,totalEntries:s.length,generatedAt:new Date().toISOString(),baseUrl:Ae(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true)},l=wr(c);return new Response(l,{headers:{"Content-Type":"application/xml","Cache-Control":"public, max-age=3600, s-maxage=3600"}})}}function po(e){return async function(){let r=[...e.staticRoutes??[],...e.getStaticRoutes?await e.getStaticRoutes():[]],n=await e.getSite(),o=await e.getArticles(),i=e.getAuthors?await e.getAuthors():[];return [...r,...await _t(n,o,i,e.options)]}}function Me(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function go(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 we={name:"@xexr/blog-platform",version:"1.1.0"};function Sr(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),o=parseInt(r[1]??"0",10),i=parseInt(r[2]?.split("-")[0]??"0",10);if(isNaN(n)||isNaN(o)||isNaN(i))throw new Error(`Invalid version format: ${e}`);return {major:n,minor:o,patch:i}}function J(){let e=Sr(we.version);return {name:we.name,version:we.version,...e}}function ie(e){try{let t=e.split(" "),r={};for(let n of t){let[o,i]=n.split("/");if(!o||!i)continue;let s=Sr(i),c={name:o,version:i,...s};o==="bloggy"?r.bloggyVersion=c:o==="platform"&&(r.platformVersion=c);}return r}catch{return null}}function Nr(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 Tr={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 ho(){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 {...Tr,enableCSP:!e,frameOptions:t??Tr.frameOptions,enableHSTS:!r}}function bo(e){return Object.entries(e).map(([t,r])=>r?`${t} ${r}`:t).join("; ")}function xo(e){return Object.entries(e).map(([t,r])=>`${t}=${r}`).join(", ")}function yo(e,t={}){let r={...ho(),...t},n={};if(r.enableCSP){let o={...r.cspDirectives,...t.cspDirectives??{}};n["Content-Security-Policy"]=bo(o);}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&&vo(e)){let o=[`max-age=${r.hstsMaxAge}`,r.hstsIncludeSubdomains?"includeSubDomains":""].filter(Boolean).join("; ");n["Strict-Transport-Security"]=o;}if(r.enablePermissionsPolicy){let o={...r.permissionsPolicyDirectives,...t.permissionsPolicyDirectives??{}};n["Permissions-Policy"]=xo(o);}return n}function vo(e){return !!(e.url.startsWith("https://")||e.headers.get("x-forwarded-proto")==="https"||e.headers.get("cf-visitor")?.includes('"scheme":"https"'))}function Qe(e,t={}){return yo(e,{...t,cspDirectives:{...{"default-src":"'none'","frame-ancestors":"'none'","base-uri":"'none'"},...t.cspDirectives??{}}})}var Rr={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 Cr(){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 {...Rr,allowedOrigins:e?e.split(",").map(n=>n.trim()):Rr.allowedOrigins,allowWildcard:t,allowCredentials:r}}function Lr(e,t){return e?t.allowWildcard?true:t.allowedOrigins.includes(e):false}function kr(e,t){let r=e.headers.get("origin"),n={};return t.allowWildcard?n["Access-Control-Allow-Origin"]="*":r&&Lr(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 Po(e,t,r,n){return {...kr(e,t),"Access-Control-Allow-Methods":r.join(", "),"Access-Control-Allow-Headers":n.join(", "),"Access-Control-Max-Age":t.maxAge.toString()}}var Ao=["Content-Type","X-Bloggy-Version","X-Idempotency-Key","Authorization","X-Requested-With"];function v(e,t,r={}){let{status:n=200,headers:o={},corsConfig:i={}}=r,s={...Cr(),...i},c=kr(e,s),l=Qe(e,s.securityConfig),u={"Content-Type":"application/json",...c,...l,...o};return NextResponse.json(t,{status:n,headers:u})}function me(e,t,r={}){let{allowedHeaders:n=Ao,corsConfig:o={}}=r,i={...Cr(),...o},s=e.headers.get("origin");if(s&&!i.allowWildcard&&!Lr(s,i)){let u=Qe(e,i.securityConfig);return new NextResponse(null,{status:403,headers:{"Content-Type":"text/plain",...u}})}let c=Po(e,i,[...t,"OPTIONS"],n),l=Qe(e,i.securityConfig);return new NextResponse(null,{status:200,headers:{...c,...l}})}async function wo(e){try{let t=await W(e);if(!t.authenticated){let p=await Q(e);return v(e,p.error,{status:401})}let r=F(t.token??"anonymous"),n=await K(r);if(!n.allowed){let p=n.errorResponse.error?.details?.rateLimit,x=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},S=B(x);return v(e,n.errorResponse,{status:429,headers:S})}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 i;try{i=await e.json();}catch{return v(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let s=So(i);if(s.length>0)return v(e,{success:!1,error:{code:"PUB001",message:"Missing required fields",details:{errors:s}},idempotencyKey:i.idempotencyKey??""},{status:400});let c=e.headers.get("X-Bloggy-Version");if(c){let p=ie(c);if(p?.platformVersion){let x=J();if(p.platformVersion.major!==x.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:x.version}},idempotencyKey:i.idempotencyKey},{status:409})}}if(i.dryRun){let p=[];return i.article.wordCount<50&&p.push("Article has fewer than 50 words, which may affect SEO"),(!i.article.excerpt||i.article.excerpt.length<120)&&p.push("Article excerpt is shorter than recommended 120 characters"),i.article.meta.keywords.length||p.push("No SEO keywords provided"),v(e,{success:!0,warnings:p,idempotencyKey:i.idempotencyKey},{status:200})}let l={...i.article,slug:i.slug??i.article.slug,meta:{...i.article.meta,description:i.metaDescription??i.article.meta.description}};if(!Bt(l.slug))return v(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:i.idempotencyKey},{status:400});let m=await M().saveArticle(l,i.idempotencyKey),a=J(),f=B(n.rateLimitResult),h={"X-Bloggy-Version":`platform/${a.version}`,"X-Idempotency-Key":i.idempotencyKey,...f};m.success&&(h.Location=m.url??`/${l.slug}`);let g=m.success?201:m.error?.code==="PUB003"?409:400;return v(e,m,{status:g,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 So(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,o=["id","slug","title","content","publishedAt","site"];for(let i of o)n[i]||t.push(`Missing required article field: ${i}`);if(n.site&&typeof n.site=="object"){let i=n.site,s=["id","name","domain"];for(let c of s)i[c]||t.push(`Missing required site field: ${c}`);}if(n.meta&&typeof n.meta=="object"){let i=n.meta;Array.isArray(i.keywords)||t.push("Article meta.keywords must be an array");}}return t}function Bt(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function To(e){try{let t=await W(e);if(!t.authenticated){let g=await Q(e);return NextResponse.json(g.error,{status:401})}let r=F(t.token??"anonymous"),n=await K(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},x=B(p);return v(e,n.errorResponse,{status:429,headers:x})}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 i;try{i=await e.json();}catch{return v(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let s=Ro(i);if(s.length>0)return v(e,{success:!1,error:{code:"PUB001",message:"Missing required fields",details:{errors:s}},idempotencyKey:i.idempotencyKey??""},{status:400});let c=e.headers.get("X-Bloggy-Version");if(c){let g=ie(c);if(g?.platformVersion){let p=J();if(g.platformVersion.major!==p.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:p.version}},idempotencyKey:i.idempotencyKey},{status:409})}}if(!Co(i.slug))return v(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:i.idempotencyKey},{status:400});if(i.dryRun){let p=await M().getArticle(i.slug),x=[];return p||x.push("Article with this slug does not exist"),v(e,{success:!0,warnings:x,idempotencyKey:i.idempotencyKey},{status:200})}let u=await M().removeArticle(i.slug,i.idempotencyKey),m=J(),a=B(n.rateLimitResult),f={"X-Bloggy-Version":`platform/${m.version}`,"X-Idempotency-Key":i.idempotencyKey,...a},h=u.success?200:u.error?.code==="PUB007"?404:400;return v(e,u,{status:h,headers:f})}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 Ro(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 Co(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function Lo(e){try{let t=await W(e);if(!t.authenticated){let a=await Q(e),f={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:a.error?.error?.message??"Authentication required"}};return v(e,f,{status:401})}let r=F(t.token??"anonymous"),n=await K(r);if(!n.allowed){let a=n.errorResponse.error?.details?.rateLimit,f=a&&typeof a=="object"&&"limit"in a&&"remaining"in a&&"reset"in a&&"count"in a&&"success"in a?a:{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},h=B(f),g={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,g,{status:429,headers:h})}let o=J(),i=e.headers.get("X-Bloggy-Version"),s={name:"unknown",version:"unknown",major:0,minor:0,patch:0};if(i)try{if(/^\d+\.\d+\.\d+/.test(i)){let a=i.split("."),f=parseInt(a[0]??"0",10),h=parseInt(a[1]??"0",10),g=parseInt(a[2]?.split("-")[0]??"0",10);s={name:"bloggy",version:i,major:f,minor:h,patch:g};}else {let a=ie(i);a?.bloggyVersion&&(s=a.bloggyVersion);}}catch(a){console.warn("Failed to parse X-Bloggy-Version header:",a);}let c={compatible:!0};s.version!=="unknown"&&(c=Nr(s,o));let l={success:!0,versions:{bloggy:s,platform:o},compatibility:c},u=B(n.rateLimitResult),m={"X-Bloggy-Version":`platform/${o.version}`,"Cache-Control":"public, max-age=300, stale-while-revalidate=60",...u};return v(e,l,{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 v(e,r,{status:500})}}var ko=/^[A-Za-z0-9-]{8,128}$/;async function _o(e){let t=await W(e);if(!t.authenticated){let l=await Q(e);return v(e,{success:false,error:{code:l.error?.error?.code??"PUB005",message:l.error?.error?.message??"Authentication required"}},{status:401})}let r=F(t.token??"anonymous"),n=await K(r);if(!n.allowed){let l=B({remaining:0,reset:Date.now()+6e4,limit:5});return v(e,{success:false,error:n.errorResponse.error??{code:"PUB011",message:"Rate limit exceeded"}},{status:429,headers:l})}if(!e.headers.get("content-type")?.includes("application/json"))return v(e,Et("Expected JSON body"),{status:400});let i;try{i=await e.json();}catch{return v(e,Et("Invalid JSON body"),{status:400})}let s=Bo(i);if(!s.success)return v(e,Et(s.message),{status:400});let c=[];return s.config.searchSubmission&&(await M().setMetadata("searchSubmission",s.config.searchSubmission),c.push("searchSubmission")),v(e,{success:true,updated:c},{status:200,headers:B(n.rateLimitResult)})}async function Io(e){return me(e,["POST"],{allowedHeaders:["Content-Type","X-Bloggy-Version","Authorization","X-Requested-With"]})}function Et(e){return {success:false,error:{code:"PUB001",message:e}}}function Bo(e){if(!e||typeof e!="object"||Array.isArray(e))return {success:false,message:"Request body must be an object"};let t=e,r=new Set(["version","searchSubmission"]),n=Object.keys(t).filter(i=>!r.has(i));if(n.length>0)return {success:false,message:`Unsupported config section: ${n.join(", ")}`};if(t.version!==1)return {success:false,message:"Config version must be 1"};let o={version:1};if(t.searchSubmission!==void 0){let i=Eo(t.searchSubmission);return i.success?{success:true,config:{...o,searchSubmission:i.config}}:i}return {success:false,message:"At least one supported config section is required"}}function Eo(e){if(!e||typeof e!="object"||Array.isArray(e))return {success:false,message:"searchSubmission must be an object"};let t=e,r=new Set(["indexNow"]),n=Object.keys(t).filter(s=>!r.has(s));if(n.length>0)return {success:false,message:`Unsupported searchSubmission section: ${n.join(", ")}`};if(t.indexNow===void 0)return {success:false,message:"searchSubmission.indexNow is required"};let o=t.indexNow;if(!o||typeof o!="object"||Array.isArray(o))return {success:false,message:"searchSubmission.indexNow must be an object"};let i=o;if(typeof i.enabled!="boolean")return {success:false,message:"indexNow.enabled must be a boolean"};if(typeof i.key!="string"||!ko.test(i.key))return {success:false,message:"indexNow.key must be 8 to 128 characters using letters, numbers, or dashes"};if(typeof i.keyLocation!="string")return {success:false,message:"indexNow.keyLocation must be a URL"};try{let s=new URL(i.keyLocation);if(s.protocol!=="https:"&&s.protocol!=="http:")return {success:!1,message:"indexNow.keyLocation must use HTTP or HTTPS"}}catch{return {success:false,message:"indexNow.keyLocation must be a URL"}}return {success:true,config:{indexNow:{enabled:i.enabled,key:i.key,keyLocation:i.keyLocation}}}}async function Oo(e){let r=(await M().getMetadata("searchSubmission"))?.indexNow;return !r?.enabled||!r.key?new NextResponse("Not found",{status:404}):new NextResponse(r.key,{status:200,headers:{"Content-Type":"text/plain; charset=utf-8","Cache-Control":"public, max-age=300, stale-while-revalidate=60"}})}async function $o(e,{params:t}){try{let{slug:r}=await t,n=await W(e);if(!n.authenticated){let p=await Q(e);return NextResponse.json(p.error,{status:401})}let o=F(n.token??"anonymous"),i=await K(o);if(!i.allowed){let p=i.errorResponse.error?.details?.rateLimit||{limit:10,remaining:0,reset:Date.now()+6e4,count:10,success:!1},x=B(p);return v(e,i.errorResponse,{status:429,headers:x})}if(!r||!Bt(r))return v(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 p=ie(s);if(p?.platformVersion){let x=J();if(p.platformVersion.major!==x.major)return v(e,{exists:!1,error:{code:"PUB009",message:"Major version incompatibility. Please upgrade your blog platform package.",details:{clientVersion:p.platformVersion.version,serverVersion:x.version}}},{status:409})}}let u=await M().getArticle(r)!==null,m={exists:u,...u&&{message:"Slug is already in use. Please choose another (e.g., append '-v2')."}},a=J(),f=B(i.rateLimitResult),h={"X-Bloggy-Version":`platform/${a.version}`,...f},g=e.headers.get("X-Idempotency-Key");return g&&(h["X-Idempotency-Key"]=g,console.log(`Slug check for idempotency: ${g}, exists: ${u}`)),v(e,m,{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 Do(e){return me(e,["GET"])}var sc=we.version;
|
|
79
|
+
export{Xe as ApiKeyAuth,kt as BLOG_PLATFORM_SCHEMA_VERSION,Ee as BLOG_PLATFORM_TABLE_NAMES,sr as BlogArticlePage,cr as BlogAuthorPage,ki as BlogAuthorsIndexPage,Vt as BlogHomePage,Oe as BlogPlatformSchemaError,Ri as BlogTopicArchivePage,Ti as BlogTopicsIndexPage,$r as Button,Ce as Card,Le as CardContent,vn as CardDescription,Pn as CardFooter,xn as CardHeader,yn as CardTitle,Nt as DrizzleStorage,ve as EnvAuth,Ve as InMemoryStorage,Fe as NEWSLETTER_SUCCESS_MESSAGE,Te as NewsletterSignup,Be as NoAuth,sc as PACKAGE_VERSION,ge as Pagination,tt as PaginationContent,De as PaginationEllipsis,Z as PaginationItem,oe as PaginationLink,nt as PaginationNext,rt as PaginationPrevious,et as ShadcnPagination,Ne as StructuredDataError,We as UninitializedAuth,St as autoConfigureRateLimit,Xi as blogPlatformDrizzleSchema,T as bpArticles,ne as bpMetadata,ue as bpOperations,_ as buildAuthorPath,N as buildBlogPath,$e as buttonVariants,yr as checkDrizzleAdapterSchema,gr as checkRateLimit,b as cn,_o as configHandler,Io as configOptionsHandler,Je as configureRateLimit,mo as createBlogSitemapRoute,po as createDynamicBlogSitemap,fr as createRateLimitErrorResponse,se as createStructuredDataScript,F as createTokenFingerprint,K as enforceRateLimit,Yi as ensureDrizzleAdapterSchema,Xr as extractKeywordsFromArticle,ut as extractTableOfContents,At as extractTokenFromHeader,ct as formatArticleDateMeta,ci as generateArticleMetadata,Ue as generateArticleStructuredData,yi as generateAuthorPageMetadata,He as generateAuthorStructuredData,gn as generateBlogHomeMetadata,lt as generateBlogHomeStructuredData,_t as generateBlogSitemapEntries,Mt as generateBreadcrumbStructuredData,de as generateCanonicalUrl,eo as generateCanonicalUrlFromSlug,at as generateCompleteArticleStructuredData,ot as generateOrganizationStructuredData,Vr as generatePaginationMetadata,io as generateSiteMetadata,lo as generateSitemap,co as generateSitemapIndex,st as generateWebSiteStructuredData,ye as getAllTopics,wi as getArticlePrimaryTopic,wt as getAuthConfig,ur as getAuthorArchive,xe as getAuthorsFromArticles,ro as getBaseUrl,j as getBlogThemeStyle,Zi as getDrizzleAdapterSql,qr as getPathPrefixFromBlogUrl,B as getRateLimitHeaders,bt as getRelatedFeaturedArticles,M as getStorage,Pt as getTopicArchive,Oo as indexNowKeyRoute,Ye as initBlogPlatform,Fi as initBlogPlatformDev,ji as initBlogPlatformOnce,Gi as initBlogPlatformProd,Oi as initEnvAuth,to as isValidCanonicalUrl,Ai as loadAuthorArchive,so as metadataToHtml,E as normalizeBlogBasePath,Ae as normalizeDomain,Ar as normalizeSlug,wo as publishHandler,Wr as safeGenerateArticleStructuredData,Ke as setAuthConfig,vt as setStorage,$i as shouldSkipAuth,wr as sitemapToXml,$o as slugExistsHandler,Do as slugExistsOptionsHandler,Dt as structuredDataToJsonLd,To as unpublishHandler,no as updateArticleCanonicalUrl,zr as usePagination,ao as validateMetadata,uo as validateSitemap,$t as validateStructuredData,Lo as versionHandler};//# sourceMappingURL=index.mjs.map
|
|
72
80
|
//# sourceMappingURL=index.mjs.map
|