@xexr/blog-platform 1.0.13 → 1.0.14
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/dist/app/blog/[slug]/page.tsx +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -11
|
@@ -539,6 +539,7 @@ export default function ArticlePage({
|
|
|
539
539
|
{(() => {
|
|
540
540
|
const structuredDataProps = createStructuredDataScript(
|
|
541
541
|
generateCompleteArticleStructuredData(article, {
|
|
542
|
+
customDomain: article.site.domain,
|
|
542
543
|
pathPrefix: normalizedBasePath,
|
|
543
544
|
}),
|
|
544
545
|
);
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
text-decoration-line: underline;
|
|
37
37
|
text-underline-offset: 0.18em;
|
|
38
38
|
}
|
|
39
|
-
`}),jsxRuntime.jsxs("header",{className:"article-header mx-auto mb-6 max-w-4xl space-y-4 text-center sm:mb-8 sm:space-y-6 lg:mb-12 lg:space-y-8",children:[jsxRuntime.jsx("h1",{className:h("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&&jsxRuntime.jsx("p",{className:"article-excerpt text-muted-foreground mx-auto mt-6 max-w-[42rem] px-4 text-lg leading-relaxed text-balance sm:mt-8 sm:max-w-[46rem] sm:px-0 sm:text-xl md:max-w-[52rem] md:text-2xl lg:max-w-4xl lg:text-2xl",children:e.excerpt}),jsxRuntime.jsxs("div",{className:"article-meta text-muted-foreground flex flex-col items-center gap-2 text-sm sm:gap-3 sm:text-base",children:[e.author&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Author"}),jsxRuntime.jsxs(J__default.default,{href:k(m,e.author.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsxRuntime.jsx(Gt,{author:e.author,size:"md"}),e.author.name]}),e.author.isGuest&&jsxRuntime.jsx(we,{variant:"outline",className:"text-xs",children:"Guest Author"})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-3 gap-y-1",children:[jsxRuntime.jsxs("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${s.publishedDateLabel}`,children:["Published ",s.publishedDateLabel]}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:s.publishedRelativeLabel}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:b})]}),s.isUpdated&&jsxRuntime.jsxs("time",{dateTime:e.updatedAt,className:"text-xs",children:["Updated ",s.updatedDateLabel]}),u&&jsxRuntime.jsx(He,{title:e.title,url:g,size:"sm"}),jsxRuntime.jsx("div",{className:"bg-border h-px w-6 sm:w-8","aria-hidden":"true"}),(e.topics??[]).length>0?jsxRuntime.jsx("nav",{"aria-label":"Article topics",className:"flex flex-wrap justify-center gap-2",children:(e.topics??[]).map(L=>jsxRuntime.jsx(J__default.default,{href:S((r?.backToHome?.url??"/blog").replace(/\/$/,""),`topics/${L.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:L.name},L.id))}):jsxRuntime.jsxs("span",{className:"text-xs tracking-wider uppercase sm:text-sm",role:"text",children:["From ",e.site.name]})]})]}),x&&jsxRuntime.jsxs("figure",{className:"article-featured-image mx-auto my-8 w-full max-w-4xl sm:my-12 lg:my-16",children:[jsxRuntime.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:jsxRuntime.jsx(lt__default.default,{src:x,alt:e.featuredImageAlt??`Featured image for ${e.title}`,className:"h-full w-full object-cover",width:800,height:450,priority:true})}),N&&jsxRuntime.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&&jsxRuntime.jsx("p",{children:e.featuredImageCaption}),(e.featuredImageCreditText??e.featuredImageCreditUrl)&&jsxRuntime.jsx("p",{className:"text-xs",children:jsxRuntime.jsx(Ln,{creditText:e.featuredImageCreditText,creditUrl:e.featuredImageCreditUrl})})]})]}),jsxRuntime.jsxs("div",{id:"article-content",className:"article-content mx-auto grid max-w-6xl grid-cols-1 gap-8 lg:grid-cols-[minmax(0,1fr)_14rem] lg:gap-12",children:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx(ut,{items:f,contentId:"article-body",variant:"mobile"}),jsxRuntime.jsx("div",{id:"article-body",className:"prose prose-sm sm:prose-base lg:prose-lg xl:prose-xl prose-gray dark:prose-invert prose-headings:scroll-mt-20 prose-headings:font-light prose-headings:text-balance prose-headings:text-[var(--blog-text-accent)] prose-h1:text-2xl sm:prose-h1:text-3xl lg:prose-h1:text-4xl prose-h2:text-xl sm:prose-h2:text-2xl lg:prose-h2:text-3xl prose-h3:text-lg sm:prose-h3:text-xl lg:prose-h3:text-2xl prose-p:leading-relaxed prose-p:text-pretty prose-a:text-[var(--blog-text-accent)] prose-a:transition-colors hover:prose-a:text-[var(--blog-text-accent-hover)] [&_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:jsxRuntime.jsx(rsc.MDXRemote,{source:e.content,options:Ut,components:{img:$t}})})]}),jsxRuntime.jsx(ut,{items:f,contentId:"article-body",variant:"desktop",showProgress:false})]}),e.author?.bio&&jsxRuntime.jsxs("div",{id:"about-author",className:"author-bio mx-auto mt-12 max-w-4xl",children:[jsxRuntime.jsx(ae,{className:"mb-8"}),jsxRuntime.jsx(Se,{className:"border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsxs(Ne,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-start sm:p-6",children:[jsxRuntime.jsx("div",{className:"shrink-0",children:jsxRuntime.jsx(Gt,{author:e.author,size:"lg"})}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm font-medium",children:"Written by"}),jsxRuntime.jsxs("h2",{className:"text-foreground flex flex-wrap items-center gap-2 text-xl font-semibold",children:[jsxRuntime.jsx(J__default.default,{href:k(m,e.author.slug),className:"transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:e.author.name}),e.author.isGuest&&jsxRuntime.jsx(we,{variant:"outline",className:"text-xs",children:"Guest Author"})]})]}),jsxRuntime.jsx(kn,{author:e.author})]}),jsxRuntime.jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.author.bio})]})]})})]}),((i??false)||(p?.enabled??false)||u||l.length>0)&&jsxRuntime.jsxs("div",{className:"mx-auto mt-12 max-w-4xl space-y-8",children:[jsxRuntime.jsx(ae,{}),i&&jsxRuntime.jsx(Bn,{cta:i}),p?.enabled&&jsxRuntime.jsx(Ae,{siteId:e.site.id,settings:p,sourceSurface:"article",sourceArticleSlug:e.slug,sourceUrl:g,previewMode:c}),u&&jsxRuntime.jsx(En,{title:e.title,url:g}),l.length>0&&jsxRuntime.jsx(On,{articles:l.slice(0,3),basePath:m})]}),(!!r?.previousArticle||!!r?.nextArticle)&&jsxRuntime.jsxs("nav",{className:"article-nav mx-auto mt-12 max-w-4xl",children:[jsxRuntime.jsx(ae,{className:"mb-8"}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[r?.previousArticle&&jsxRuntime.jsx(Se,{className:"group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsxs(J__default.default,{href:r.previousArticle.url,className:"block",children:[r.previousArticle.featuredImage&&jsxRuntime.jsx(pt,{src:r.previousArticle.featuredImage,alt:r.previousArticle.featuredImageAlt??`Featured image for ${r.previousArticle.title}`}),jsxRuntime.jsxs(Ne,{className:"p-4",children:[jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"\u2190 Previous Article"}),jsxRuntime.jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.previousArticle.title})]})]})}),r?.nextArticle&&jsxRuntime.jsx(Se,{className:h("group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",!r?.previousArticle&&"md:col-start-2"),children:jsxRuntime.jsxs(J__default.default,{href:r.nextArticle.url,className:"block",children:[r.nextArticle.featuredImage&&jsxRuntime.jsx(pt,{src:r.nextArticle.featuredImage,alt:r.nextArticle.featuredImageAlt??`Featured image for ${r.nextArticle.title}`}),jsxRuntime.jsxs(Ne,{className:"p-4 md:text-right",children:[jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"Next Article \u2192"}),jsxRuntime.jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.nextArticle.title})]})]})})]})]}),(()=>{let L=ie(nt(e,{pathPrefix:m}));return jsxRuntime.jsx("script",{type:L.type,dangerouslySetInnerHTML:L.dangerouslySetInnerHTML})})()]})}function Gt({author:e,size:t}){let r=t==="lg"?"h-12 w-12 text-base":"h-9 w-9 text-sm",n=In(e.name);return e.avatarUrl?jsxRuntime.jsx(lt__default.default,{src:e.avatarUrl,alt:e.name,width:t==="lg"?48:36,height:t==="lg"?48:36,className:h("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsxRuntime.jsx("span",{className:h("bg-muted text-muted-foreground inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function kn({author:e}){let t=_n(e);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:t.map(r=>jsxRuntime.jsx("a",{href:r.href,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,"aria-label":`${e.name} ${r.label}`,className:"text-muted-foreground hover:bg-background/60 hover:text-foreground inline-flex size-7 items-center justify-center rounded-full transition-colors",children:r.icon},r.key))})}function _n(e){let t=e.socialLinks;return t?[t.website?{key:"website",href:t.website,label:"website",external:true,icon:jsxRuntime.jsx(lucideReact.Globe,{className:"size-4","aria-hidden":"true"})}:void 0,t.x?{key:"x",href:t.x,label:"on X",external:true,icon:jsxRuntime.jsx(fa6.FaXTwitter,{className:"size-4","aria-hidden":"true"})}:void 0,t.linkedin?{key:"linkedin",href:t.linkedin,label:"on LinkedIn",external:true,icon:jsxRuntime.jsx(fa6.FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}:void 0,t.github?{key:"github",href:t.github,label:"on GitHub",external:true,icon:jsxRuntime.jsx(fa6.FaGithub,{className:"size-4","aria-hidden":"true"})}:void 0,t.email?{key:"email",href:`mailto:${t.email}`,label:"email",external:false,icon:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})}:void 0].filter(n=>!!n):[]}function In(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function Bn({cta:e}){return jsxRuntime.jsx("div",{className:"rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] p-5 sm:p-6",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("h2",{className:"text-foreground text-xl font-semibold",children:e.title}),e.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.description})]}),jsxRuntime.jsxs(J__default.default,{href:e.href,className:"inline-flex shrink-0 items-center justify-center gap-2 rounded-full bg-[var(--blog-accent)] px-4 py-2 text-sm font-semibold text-white transition-opacity hover:opacity-90",children:[e.label,jsxRuntime.jsx(lucideReact.ArrowUpRight,{className:"size-4","aria-hidden":"true"})]})]})})}function En({title:e,url:t}){let r=encodeURIComponent(e),n=encodeURIComponent(t);return jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2 sm:gap-3",children:[jsxRuntime.jsx(He,{title:e,url:t,size:"sm"}),jsxRuntime.jsx("a",{href:`https://x.com/intent/tweet?text=${r}&url=${n}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Share on X",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(fa6.FaXTwitter,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsx("a",{href:`https://www.linkedin.com/sharing/share-offsite/?url=${n}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Share on LinkedIn",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(fa6.FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsx("a",{href:`mailto:?subject=${r}&body=${n}`,"aria-label":"Share by email",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})})]})}function On({articles:e,basePath:t}){return jsxRuntime.jsxs("section",{className:"space-y-4","aria-labelledby":"related-articles-title",children:[jsxRuntime.jsx("h2",{id:"related-articles-title",className:"text-xl font-semibold",children:"You might also like"}),jsxRuntime.jsx("div",{className:"grid gap-4 md:grid-cols-3",children:e.map(r=>jsxRuntime.jsxs(J__default.default,{href:S(t,r.slug),className:"group border-border overflow-hidden rounded-2xl border transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)] hover:no-underline",children:[r.featuredImage&&jsxRuntime.jsx(pt,{src:r.featuredImage,alt:r.featuredImageAlt??`Featured image for ${r.title}`}),jsxRuntime.jsxs("div",{className:"p-4",children:[jsxRuntime.jsx("h3",{className:"text-foreground line-clamp-3 font-semibold transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.title}),r.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:r.excerpt})]})]},r.id))})]})}function pt({src:e,alt:t}){return jsxRuntime.jsx("div",{className:"border-border aspect-[16/9] overflow-hidden border-b bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(lt__default.default,{src:e,alt:t,width:480,height:270,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"})})}function Mn(e,t="/blog"){let r=e.meta.title??e.title,n=e.meta.description??e.excerpt,o=e.meta.canonicalUrl??`${e.site.domain}${S(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 Wt({author:e,articles:t,site:r,className:n,basePath:o="/blog",theme:i,pagination:a,navigation:c}){let l=E(o)||"/",u=c?.backToHome?.url??l,m=k(l,e.slug),s=a?.totalItems??t.length,b=ie(Me(e,{pathPrefix:l}));return jsxRuntime.jsxs("main",{style:U(i),className:h("author-page mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",n),children:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-8 sm:mb-14",children:[jsxRuntime.jsxs(J__default.default,{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:[jsxRuntime.jsx(lucideReact.ArrowLeft,{className:"size-4 transition-transform group-hover:-translate-x-1","aria-hidden":"true"}),c?.backToHome?.label??"Back to all articles"]}),jsxRuntime.jsxs("div",{className:"grid gap-6 sm:grid-cols-[auto_minmax(0,1fr)] sm:items-center",children:[jsxRuntime.jsx(zn,{author:e}),jsxRuntime.jsxs("div",{className:"min-w-0 space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.isGuest&&jsxRuntime.jsx(we,{variant:"outline",className:"text-xs",children:"Guest Author"})}),jsxRuntime.jsx("h1",{className:h("text-4xl leading-tight font-light text-balance sm:text-5xl",G),children:e.name})]}),e.bio&&jsxRuntime.jsx("p",{className:"text-muted-foreground max-w-3xl text-lg leading-relaxed text-pretty",children:e.bio}),jsxRuntime.jsx(Gn,{author:e})]})]})]}),jsxRuntime.jsx(ae,{className:"mb-8"}),jsxRuntime.jsxs("section",{"aria-labelledby":"author-articles-title",className:"space-y-6",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap items-end justify-between gap-3",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h2",{id:"author-articles-title",className:"text-foreground text-2xl font-semibold",children:["Articles by ",e.name]}),jsxRuntime.jsxs("p",{className:"text-muted-foreground mt-1 text-sm",children:[s," ",s===1?"article":"articles"," on ",r.name]})]})}),t.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground border-border rounded-2xl border p-6",children:"This author does not have any published articles yet."}):jsxRuntime.jsx("div",{className:"divide-border divide-y",children:t.map(f=>jsxRuntime.jsx(Fn,{article:f,basePath:l},f.id))}),a&&a.totalPages>1&&jsxRuntime.jsx("div",{className:"pt-4",children:jsxRuntime.jsx(ce,{currentPage:a.currentPage,totalPages:a.totalPages,baseUrl:a.baseUrl??m,className:"justify-center"})})]}),jsxRuntime.jsx("script",{type:b.type,dangerouslySetInnerHTML:b.dangerouslySetInnerHTML})]})}function Gn({author:e}){let t=jn(e);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-2","aria-label":"Author links",children:t.map(r=>jsxRuntime.jsx("a",{href:r.href,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,"aria-label":r.ariaLabel,className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:r.icon},r.label))})}function jn(e){let t=e.socialLinks;return t?[t.website?{href:t.website,label:"website",ariaLabel:`${e.name}'s website`,external:true,icon:jsxRuntime.jsx(lucideReact.Globe,{className:"size-4","aria-hidden":"true"})}:null,t.x??t.twitter?{href:t.x??t.twitter??"",label:"x",ariaLabel:`${e.name} on X`,external:true,icon:jsxRuntime.jsx("span",{className:"text-sm font-semibold","aria-hidden":"true",children:"X"})}:null,t.linkedin?{href:t.linkedin,label:"linkedin",ariaLabel:`${e.name} on LinkedIn`,external:true,icon:jsxRuntime.jsx("span",{className:"text-sm font-bold","aria-hidden":"true",children:"in"})}:null,t.github?{href:t.github,label:"github",ariaLabel:`${e.name} on GitHub`,external:true,icon:jsxRuntime.jsx("span",{className:"text-xs font-bold","aria-hidden":"true",children:"GH"})}:null,t.email?{href:`mailto:${t.email}`,label:"email",ariaLabel:`Email ${e.name}`,external:false,icon:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})}:null].filter(r=>r!==null):[]}function Fn({article:e,basePath:t}){let r=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxRuntime.jsx("article",{className:"py-6 first:pt-0 last:pb-0",children:jsxRuntime.jsxs(J__default.default,{href:S(t,e.slug),className:"group grid gap-4 hover:no-underline sm:grid-cols-[minmax(0,1fr)_12rem] sm:items-start",children:[jsxRuntime.jsxs("div",{className:"min-w-0 space-y-3",children:[jsxRuntime.jsx("h3",{className:"text-xl leading-tight font-semibold text-balance transition-colors group-hover:text-[var(--blog-text-accent)]",children:e.title}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 leading-relaxed",children:e.excerpt}),jsxRuntime.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[jsxRuntime.jsx("time",{dateTime:e.publishedAt,children:r}),jsxRuntime.jsx("span",{"aria-hidden":"true",children:"\u2022"}),jsxRuntime.jsxs("span",{children:[Math.ceil(e.readingSeconds/60)," min read"]})]})]}),e.featuredImage&&jsxRuntime.jsx("div",{className:"border-border relative aspect-[16/10] overflow-hidden rounded-xl border bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(lt__default.default,{src:e.featuredImage,alt:e.featuredImageAlt??`Featured image for ${e.title}`,width:320,height:200,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"})})]})})}function zn({author:e}){return e.avatarUrl?jsxRuntime.jsx(lt__default.default,{src:e.avatarUrl,alt:e.name,width:128,height:128,className:"size-28 rounded-full border border-[var(--blog-accent-border)] object-cover sm:size-32",priority:true}):jsxRuntime.jsx("span",{className:"bg-muted text-muted-foreground inline-flex size-28 items-center justify-center rounded-full text-3xl font-semibold sm:size-32",children:Vn(e.name)})}function Vn(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 Ge=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 Xn(){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 Wn(){let e=globalThis;e.__BLOG_PLATFORM_STORAGE__||(Xn(),e.__BLOG_PLATFORM_STORAGE__=new Ge);let t=e.__BLOG_PLATFORM_STORAGE__;if(!t)throw new Error("Blog platform storage not initialized");return t}function q(){return Wn()}function ft(e){let t=globalThis;t.__BLOG_PLATFORM_STORAGE__=e;}function pe(e){let t=new Map;for(let r of e)r.author?.slug&&t.set(r.author.slug,Jt(t.get(r.author.slug),r.author));return Array.from(t.values()).sort((r,n)=>r.name.localeCompare(n.name))}function Kt(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?Jt(o,i.author):o,null);return n?{author:n,articles:r}:null}async function Kn(e,t={},r=q()){let{articles:n}=await r.listArticles({limit:t.limit??1e3,offset:t.offset??0,sortBy:"publishedAt",order:"desc"});return Kt(e,n)}function Jt(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 Jn(e){let t=e.topics??[];return t.find(r=>r.isPrimary)??t[0]??null}function ge(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 ht(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 Zn({articles:e,basePath:t="/blog",title:r="Topics",description:n="Browse articles by topic.",className:o,theme:i}){let a=E(t)||"/",c=ge(e);return jsxRuntime.jsxs("main",{style:U(i),className:h("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:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(J__default.default,{href:a,className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all articles"}),jsxRuntime.jsx("h1",{className:h("text-4xl font-light tracking-tight text-balance sm:text-5xl",G),children:r}),jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),c.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No topics have published articles yet."}):jsxRuntime.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:c.map(l=>{let u=e.filter(m=>(m.topics??[]).some(s=>s.slug===l.slug)).length;return jsxRuntime.jsxs(J__default.default,{href:S(a,`topics/${l.slug}`),className:"group rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] p-5 transition hover:border-[var(--blog-accent)] hover:no-underline",children:[jsxRuntime.jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold transition-colors",children:l.name}),l.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:l.description}),jsxRuntime.jsxs("p",{className:"text-muted-foreground mt-4 text-sm",children:[u," ",u===1?"article":"articles"]})]},l.slug)})})]})}function ei({articles:e,topicSlug:t,basePath:r="/blog",className:n,theme:o}){let i=E(r)||"/",a=ht(e,t);return jsxRuntime.jsxs("main",{style:U(o),className:h("blog-topic-archive-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",n),children:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(J__default.default,{href:S(i,"topics"),className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all topics"}),jsxRuntime.jsx("h1",{className:h("text-4xl font-light tracking-tight text-balance sm:text-5xl",G),children:a?.topic.name??"Topic not found"}),a?.topic.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:a.topic.description})]}),a?jsxRuntime.jsx("div",{className:"grid gap-5 md:grid-cols-2",children:a.articles.map(c=>jsxRuntime.jsx(ti,{article:c,topic:a.topic,basePath:i},c.id))}):jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No published articles were found for this topic."})]})}function ti({article:e,topic:t,basePath:r}){let n=S(r,e.slug),o=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxRuntime.jsxs(J__default.default,{href:n,className:"group overflow-hidden rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] transition hover:border-[var(--blog-accent)] hover:no-underline",children:[e.featuredImage&&jsxRuntime.jsx("div",{className:"relative aspect-[16/9] overflow-hidden",children:jsxRuntime.jsx(lt__default.default,{src:e.featuredImage,alt:e.featuredImageAlt??e.title,width:640,height:360,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})}),jsxRuntime.jsxs("div",{className:"space-y-3 p-5",children:[jsxRuntime.jsx("span",{className:"inline-flex rounded-full border border-[var(--blog-accent-border)] px-2.5 py-1 text-xs font-medium text-[var(--blog-text-accent)]",children:t.name}),jsxRuntime.jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold text-balance transition-colors",children:e.title}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:e.excerpt}),jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm",children:o})]})]})}function ni({articles:e,basePath:t="/blog",title:r="Authors",description:n="Browse articles by author.",className:o,theme:i}){let a=E(t)||"/",c=pe(e);return jsxRuntime.jsxs("main",{style:U(i),className:h("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:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(J__default.default,{href:a,className:"text-muted-foreground text-sm font-medium transition-colors hover:text-[var(--blog-accent)]",children:"Back to all articles"}),jsxRuntime.jsx("h1",{className:h("text-4xl font-light tracking-tight text-balance sm:text-5xl",G),children:r}),jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),c.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No authors have published articles yet."}):jsxRuntime.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:c.map(l=>{let u=e.filter(m=>m.author?.slug===l.slug).length;return jsxRuntime.jsx(J__default.default,{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:jsxRuntime.jsxs("div",{className:"flex items-start gap-4",children:[jsxRuntime.jsx(ii,{author:l}),jsxRuntime.jsxs("div",{className:"min-w-0 space-y-2",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold transition-colors group-hover:text-[var(--blog-accent)]",children:l.name}),l.bio&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:l.bio}),jsxRuntime.jsxs("p",{className:"text-muted-foreground text-sm",children:[u," ",u===1?"article":"articles"]})]})]})},l.slug)})})]})}function ii({author:e}){let t=oi(e.name);return e.avatarUrl?jsxRuntime.jsx(lt__default.default,{src:e.avatarUrl,alt:e.name,width:56,height:56,className:"size-14 shrink-0 rounded-full border border-[var(--blog-accent-border)] object-cover"}):jsxRuntime.jsx("span",{className:"bg-muted text-muted-foreground inline-flex size-14 shrink-0 items-center justify-center rounded-full text-base font-semibold",children:t})}function oi(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function X(e){return `sha256:${crypto.createHash("sha256").update(e).digest("hex")}`}function bt(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 Fe=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=>bt(t);hashToken(t){return X(t)}},fe=class extends Fe{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 si(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??=new ze,globalThis.__BLOG_PLATFORM_AUTH_CONFIG__}function Ve(e){globalThis.__BLOG_PLATFORM_AUTH_CONFIG__=e;}function xt(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??si()}function li(e){Ve(new fe(e));}async function Y(e){let t=xt(),r=t.extractToken?t.extractToken(e):bt(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 ci(e,t=""){let n=xt().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 te(e){let t=await Y(e);return t.authenticated?{authenticated:true,context:t.result.context}:{authenticated:false,error:ci(t.result)}}function ui(){let e=process.env.SKIP_BLOG_PLATFORM_AUTH;return e==="true"||e==="1"||process.env.NODE_ENV==="test"}function mi(){return globalThis.__BLOG_PLATFORM_RATE_LIMITER__??null}function pi(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.Redis({url:t,token:r}),c=new ratelimit.Ratelimit({redis:a,analytics:i,prefix:o,limiter:ratelimit.Ratelimit.slidingWindow(n,"1m")});pi(c);}function yt(){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 Zt(e){let t=mi();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 er(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 Q(e,t=""){let r=await Zt(e);return r.success?{allowed:true,rateLimitResult:r}:{allowed:false,errorResponse:er(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
|
+
`}),jsxRuntime.jsxs("header",{className:"article-header mx-auto mb-6 max-w-4xl space-y-4 text-center sm:mb-8 sm:space-y-6 lg:mb-12 lg:space-y-8",children:[jsxRuntime.jsx("h1",{className:h("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&&jsxRuntime.jsx("p",{className:"article-excerpt text-muted-foreground mx-auto mt-6 max-w-[42rem] px-4 text-lg leading-relaxed text-balance sm:mt-8 sm:max-w-[46rem] sm:px-0 sm:text-xl md:max-w-[52rem] md:text-2xl lg:max-w-4xl lg:text-2xl",children:e.excerpt}),jsxRuntime.jsxs("div",{className:"article-meta text-muted-foreground flex flex-col items-center gap-2 text-sm sm:gap-3 sm:text-base",children:[e.author&&jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("span",{className:"sr-only",children:"Author"}),jsxRuntime.jsxs(J__default.default,{href:k(m,e.author.slug),className:"inline-flex items-center gap-2 font-medium transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:[jsxRuntime.jsx(Gt,{author:e.author,size:"md"}),e.author.name]}),e.author.isGuest&&jsxRuntime.jsx(we,{variant:"outline",className:"text-xs",children:"Guest Author"})]}),jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-3 gap-y-1",children:[jsxRuntime.jsxs("time",{dateTime:e.publishedAt,className:"font-medium","aria-label":`Published ${s.publishedDateLabel}`,children:["Published ",s.publishedDateLabel]}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:s.publishedRelativeLabel}),jsxRuntime.jsx("span",{className:"text-border",children:"\u2022"}),jsxRuntime.jsx("span",{className:"font-medium",children:b})]}),s.isUpdated&&jsxRuntime.jsxs("time",{dateTime:e.updatedAt,className:"text-xs",children:["Updated ",s.updatedDateLabel]}),u&&jsxRuntime.jsx(He,{title:e.title,url:g,size:"sm"}),jsxRuntime.jsx("div",{className:"bg-border h-px w-6 sm:w-8","aria-hidden":"true"}),(e.topics??[]).length>0?jsxRuntime.jsx("nav",{"aria-label":"Article topics",className:"flex flex-wrap justify-center gap-2",children:(e.topics??[]).map(L=>jsxRuntime.jsx(J__default.default,{href:S((r?.backToHome?.url??"/blog").replace(/\/$/,""),`topics/${L.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:L.name},L.id))}):jsxRuntime.jsxs("span",{className:"text-xs tracking-wider uppercase sm:text-sm",role:"text",children:["From ",e.site.name]})]})]}),x&&jsxRuntime.jsxs("figure",{className:"article-featured-image mx-auto my-8 w-full max-w-4xl sm:my-12 lg:my-16",children:[jsxRuntime.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:jsxRuntime.jsx(lt__default.default,{src:x,alt:e.featuredImageAlt??`Featured image for ${e.title}`,className:"h-full w-full object-cover",width:800,height:450,priority:true})}),N&&jsxRuntime.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&&jsxRuntime.jsx("p",{children:e.featuredImageCaption}),(e.featuredImageCreditText??e.featuredImageCreditUrl)&&jsxRuntime.jsx("p",{className:"text-xs",children:jsxRuntime.jsx(Ln,{creditText:e.featuredImageCreditText,creditUrl:e.featuredImageCreditUrl})})]})]}),jsxRuntime.jsxs("div",{id:"article-content",className:"article-content mx-auto grid max-w-6xl grid-cols-1 gap-8 lg:grid-cols-[minmax(0,1fr)_14rem] lg:gap-12",children:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx(ut,{items:f,contentId:"article-body",variant:"mobile"}),jsxRuntime.jsx("div",{id:"article-body",className:"prose prose-sm sm:prose-base lg:prose-lg xl:prose-xl prose-gray dark:prose-invert prose-headings:scroll-mt-20 prose-headings:font-light prose-headings:text-balance prose-headings:text-[var(--blog-text-accent)] prose-h1:text-2xl sm:prose-h1:text-3xl lg:prose-h1:text-4xl prose-h2:text-xl sm:prose-h2:text-2xl lg:prose-h2:text-3xl prose-h3:text-lg sm:prose-h3:text-xl lg:prose-h3:text-2xl prose-p:leading-relaxed prose-p:text-pretty prose-a:text-[var(--blog-text-accent)] prose-a:transition-colors hover:prose-a:text-[var(--blog-text-accent-hover)] [&_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:jsxRuntime.jsx(rsc.MDXRemote,{source:e.content,options:Ut,components:{img:$t}})})]}),jsxRuntime.jsx(ut,{items:f,contentId:"article-body",variant:"desktop",showProgress:false})]}),e.author?.bio&&jsxRuntime.jsxs("div",{id:"about-author",className:"author-bio mx-auto mt-12 max-w-4xl",children:[jsxRuntime.jsx(ae,{className:"mb-8"}),jsxRuntime.jsx(Se,{className:"border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsxs(Ne,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-start sm:p-6",children:[jsxRuntime.jsx("div",{className:"shrink-0",children:jsxRuntime.jsx(Gt,{author:e.author,size:"lg"})}),jsxRuntime.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[jsxRuntime.jsxs("div",{className:"min-w-0",children:[jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm font-medium",children:"Written by"}),jsxRuntime.jsxs("h2",{className:"text-foreground flex flex-wrap items-center gap-2 text-xl font-semibold",children:[jsxRuntime.jsx(J__default.default,{href:k(m,e.author.slug),className:"transition-colors hover:text-[var(--blog-accent)] hover:no-underline",children:e.author.name}),e.author.isGuest&&jsxRuntime.jsx(we,{variant:"outline",className:"text-xs",children:"Guest Author"})]})]}),jsxRuntime.jsx(kn,{author:e.author})]}),jsxRuntime.jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.author.bio})]})]})})]}),((i??false)||(p?.enabled??false)||u||l.length>0)&&jsxRuntime.jsxs("div",{className:"mx-auto mt-12 max-w-4xl space-y-8",children:[jsxRuntime.jsx(ae,{}),i&&jsxRuntime.jsx(Bn,{cta:i}),p?.enabled&&jsxRuntime.jsx(Ae,{siteId:e.site.id,settings:p,sourceSurface:"article",sourceArticleSlug:e.slug,sourceUrl:g,previewMode:c}),u&&jsxRuntime.jsx(En,{title:e.title,url:g}),l.length>0&&jsxRuntime.jsx(On,{articles:l.slice(0,3),basePath:m})]}),(!!r?.previousArticle||!!r?.nextArticle)&&jsxRuntime.jsxs("nav",{className:"article-nav mx-auto mt-12 max-w-4xl",children:[jsxRuntime.jsx(ae,{className:"mb-8"}),jsxRuntime.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[r?.previousArticle&&jsxRuntime.jsx(Se,{className:"group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsxs(J__default.default,{href:r.previousArticle.url,className:"block",children:[r.previousArticle.featuredImage&&jsxRuntime.jsx(pt,{src:r.previousArticle.featuredImage,alt:r.previousArticle.featuredImageAlt??`Featured image for ${r.previousArticle.title}`}),jsxRuntime.jsxs(Ne,{className:"p-4",children:[jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"\u2190 Previous Article"}),jsxRuntime.jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.previousArticle.title})]})]})}),r?.nextArticle&&jsxRuntime.jsx(Se,{className:h("group cursor-pointer transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",!r?.previousArticle&&"md:col-start-2"),children:jsxRuntime.jsxs(J__default.default,{href:r.nextArticle.url,className:"block",children:[r.nextArticle.featuredImage&&jsxRuntime.jsx(pt,{src:r.nextArticle.featuredImage,alt:r.nextArticle.featuredImageAlt??`Featured image for ${r.nextArticle.title}`}),jsxRuntime.jsxs(Ne,{className:"p-4 md:text-right",children:[jsxRuntime.jsx("div",{className:"text-muted-foreground mb-2 text-sm font-medium",children:"Next Article \u2192"}),jsxRuntime.jsx("div",{className:"text-foreground transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.nextArticle.title})]})]})})]})]}),(()=>{let L=ie(nt(e,{customDomain:e.site.domain,pathPrefix:m}));return jsxRuntime.jsx("script",{type:L.type,dangerouslySetInnerHTML:L.dangerouslySetInnerHTML})})()]})}function Gt({author:e,size:t}){let r=t==="lg"?"h-12 w-12 text-base":"h-9 w-9 text-sm",n=In(e.name);return e.avatarUrl?jsxRuntime.jsx(lt__default.default,{src:e.avatarUrl,alt:e.name,width:t==="lg"?48:36,height:t==="lg"?48:36,className:h("shrink-0 rounded-full object-cover",r),loading:"lazy"}):jsxRuntime.jsx("span",{className:h("bg-muted text-muted-foreground inline-flex shrink-0 items-center justify-center rounded-full font-medium",r),"aria-hidden":"true",children:n})}function kn({author:e}){let t=_n(e);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-1 sm:justify-end",children:t.map(r=>jsxRuntime.jsx("a",{href:r.href,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,"aria-label":`${e.name} ${r.label}`,className:"text-muted-foreground hover:bg-background/60 hover:text-foreground inline-flex size-7 items-center justify-center rounded-full transition-colors",children:r.icon},r.key))})}function _n(e){let t=e.socialLinks;return t?[t.website?{key:"website",href:t.website,label:"website",external:true,icon:jsxRuntime.jsx(lucideReact.Globe,{className:"size-4","aria-hidden":"true"})}:void 0,t.x?{key:"x",href:t.x,label:"on X",external:true,icon:jsxRuntime.jsx(fa6.FaXTwitter,{className:"size-4","aria-hidden":"true"})}:void 0,t.linkedin?{key:"linkedin",href:t.linkedin,label:"on LinkedIn",external:true,icon:jsxRuntime.jsx(fa6.FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}:void 0,t.github?{key:"github",href:t.github,label:"on GitHub",external:true,icon:jsxRuntime.jsx(fa6.FaGithub,{className:"size-4","aria-hidden":"true"})}:void 0,t.email?{key:"email",href:`mailto:${t.email}`,label:"email",external:false,icon:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})}:void 0].filter(n=>!!n):[]}function In(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function Bn({cta:e}){return jsxRuntime.jsx("div",{className:"rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-accent-bg)] p-5 sm:p-6",children:jsxRuntime.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[jsxRuntime.jsxs("div",{className:"space-y-1",children:[jsxRuntime.jsx("h2",{className:"text-foreground text-xl font-semibold",children:e.title}),e.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground leading-relaxed",children:e.description})]}),jsxRuntime.jsxs(J__default.default,{href:e.href,className:"inline-flex shrink-0 items-center justify-center gap-2 rounded-full bg-[var(--blog-accent)] px-4 py-2 text-sm font-semibold text-white transition-opacity hover:opacity-90",children:[e.label,jsxRuntime.jsx(lucideReact.ArrowUpRight,{className:"size-4","aria-hidden":"true"})]})]})})}function En({title:e,url:t}){let r=encodeURIComponent(e),n=encodeURIComponent(t);return jsxRuntime.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2 sm:gap-3",children:[jsxRuntime.jsx(He,{title:e,url:t,size:"sm"}),jsxRuntime.jsx("a",{href:`https://x.com/intent/tweet?text=${r}&url=${n}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Share on X",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(fa6.FaXTwitter,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsx("a",{href:`https://www.linkedin.com/sharing/share-offsite/?url=${n}`,target:"_blank",rel:"noopener noreferrer","aria-label":"Share on LinkedIn",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(fa6.FaLinkedinIn,{className:"size-4","aria-hidden":"true"})}),jsxRuntime.jsx("a",{href:`mailto:?subject=${r}&body=${n}`,"aria-label":"Share by email",className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})})]})}function On({articles:e,basePath:t}){return jsxRuntime.jsxs("section",{className:"space-y-4","aria-labelledby":"related-articles-title",children:[jsxRuntime.jsx("h2",{id:"related-articles-title",className:"text-xl font-semibold",children:"You might also like"}),jsxRuntime.jsx("div",{className:"grid gap-4 md:grid-cols-3",children:e.map(r=>jsxRuntime.jsxs(J__default.default,{href:S(t,r.slug),className:"group border-border overflow-hidden rounded-2xl border transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)] hover:no-underline",children:[r.featuredImage&&jsxRuntime.jsx(pt,{src:r.featuredImage,alt:r.featuredImageAlt??`Featured image for ${r.title}`}),jsxRuntime.jsxs("div",{className:"p-4",children:[jsxRuntime.jsx("h3",{className:"text-foreground line-clamp-3 font-semibold transition-colors group-hover:text-[var(--blog-text-accent)]",children:r.title}),r.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:r.excerpt})]})]},r.id))})]})}function pt({src:e,alt:t}){return jsxRuntime.jsx("div",{className:"border-border aspect-[16/9] overflow-hidden border-b bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(lt__default.default,{src:e,alt:t,width:480,height:270,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"})})}function Mn(e,t="/blog"){let r=e.meta.title??e.title,n=e.meta.description??e.excerpt,o=e.meta.canonicalUrl??`${e.site.domain}${S(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 Wt({author:e,articles:t,site:r,className:n,basePath:o="/blog",theme:i,pagination:a,navigation:c}){let l=E(o)||"/",u=c?.backToHome?.url??l,m=k(l,e.slug),s=a?.totalItems??t.length,b=ie(Me(e,{pathPrefix:l}));return jsxRuntime.jsxs("main",{style:U(i),className:h("author-page mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",n),children:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-8 sm:mb-14",children:[jsxRuntime.jsxs(J__default.default,{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:[jsxRuntime.jsx(lucideReact.ArrowLeft,{className:"size-4 transition-transform group-hover:-translate-x-1","aria-hidden":"true"}),c?.backToHome?.label??"Back to all articles"]}),jsxRuntime.jsxs("div",{className:"grid gap-6 sm:grid-cols-[auto_minmax(0,1fr)] sm:items-center",children:[jsxRuntime.jsx(zn,{author:e}),jsxRuntime.jsxs("div",{className:"min-w-0 space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.isGuest&&jsxRuntime.jsx(we,{variant:"outline",className:"text-xs",children:"Guest Author"})}),jsxRuntime.jsx("h1",{className:h("text-4xl leading-tight font-light text-balance sm:text-5xl",G),children:e.name})]}),e.bio&&jsxRuntime.jsx("p",{className:"text-muted-foreground max-w-3xl text-lg leading-relaxed text-pretty",children:e.bio}),jsxRuntime.jsx(Gn,{author:e})]})]})]}),jsxRuntime.jsx(ae,{className:"mb-8"}),jsxRuntime.jsxs("section",{"aria-labelledby":"author-articles-title",className:"space-y-6",children:[jsxRuntime.jsx("div",{className:"flex flex-wrap items-end justify-between gap-3",children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("h2",{id:"author-articles-title",className:"text-foreground text-2xl font-semibold",children:["Articles by ",e.name]}),jsxRuntime.jsxs("p",{className:"text-muted-foreground mt-1 text-sm",children:[s," ",s===1?"article":"articles"," on ",r.name]})]})}),t.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground border-border rounded-2xl border p-6",children:"This author does not have any published articles yet."}):jsxRuntime.jsx("div",{className:"divide-border divide-y",children:t.map(f=>jsxRuntime.jsx(Fn,{article:f,basePath:l},f.id))}),a&&a.totalPages>1&&jsxRuntime.jsx("div",{className:"pt-4",children:jsxRuntime.jsx(ce,{currentPage:a.currentPage,totalPages:a.totalPages,baseUrl:a.baseUrl??m,className:"justify-center"})})]}),jsxRuntime.jsx("script",{type:b.type,dangerouslySetInnerHTML:b.dangerouslySetInnerHTML})]})}function Gn({author:e}){let t=jn(e);return t.length===0?null:jsxRuntime.jsx("div",{className:"flex flex-wrap items-center gap-2","aria-label":"Author links",children:t.map(r=>jsxRuntime.jsx("a",{href:r.href,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,"aria-label":r.ariaLabel,className:"text-muted-foreground hover:text-foreground border-border inline-flex size-9 items-center justify-center rounded-full border grayscale transition-colors hover:border-[var(--blog-accent-border)] hover:bg-[var(--blog-accent-bg)]",children:r.icon},r.label))})}function jn(e){let t=e.socialLinks;return t?[t.website?{href:t.website,label:"website",ariaLabel:`${e.name}'s website`,external:true,icon:jsxRuntime.jsx(lucideReact.Globe,{className:"size-4","aria-hidden":"true"})}:null,t.x??t.twitter?{href:t.x??t.twitter??"",label:"x",ariaLabel:`${e.name} on X`,external:true,icon:jsxRuntime.jsx("span",{className:"text-sm font-semibold","aria-hidden":"true",children:"X"})}:null,t.linkedin?{href:t.linkedin,label:"linkedin",ariaLabel:`${e.name} on LinkedIn`,external:true,icon:jsxRuntime.jsx("span",{className:"text-sm font-bold","aria-hidden":"true",children:"in"})}:null,t.github?{href:t.github,label:"github",ariaLabel:`${e.name} on GitHub`,external:true,icon:jsxRuntime.jsx("span",{className:"text-xs font-bold","aria-hidden":"true",children:"GH"})}:null,t.email?{href:`mailto:${t.email}`,label:"email",ariaLabel:`Email ${e.name}`,external:false,icon:jsxRuntime.jsx(lucideReact.Mail,{className:"size-4","aria-hidden":"true"})}:null].filter(r=>r!==null):[]}function Fn({article:e,basePath:t}){let r=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxRuntime.jsx("article",{className:"py-6 first:pt-0 last:pb-0",children:jsxRuntime.jsxs(J__default.default,{href:S(t,e.slug),className:"group grid gap-4 hover:no-underline sm:grid-cols-[minmax(0,1fr)_12rem] sm:items-start",children:[jsxRuntime.jsxs("div",{className:"min-w-0 space-y-3",children:[jsxRuntime.jsx("h3",{className:"text-xl leading-tight font-semibold text-balance transition-colors group-hover:text-[var(--blog-text-accent)]",children:e.title}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 leading-relaxed",children:e.excerpt}),jsxRuntime.jsxs("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-3 gap-y-1 text-sm",children:[jsxRuntime.jsx("time",{dateTime:e.publishedAt,children:r}),jsxRuntime.jsx("span",{"aria-hidden":"true",children:"\u2022"}),jsxRuntime.jsxs("span",{children:[Math.ceil(e.readingSeconds/60)," min read"]})]})]}),e.featuredImage&&jsxRuntime.jsx("div",{className:"border-border relative aspect-[16/10] overflow-hidden rounded-xl border bg-[var(--blog-accent-bg)]",children:jsxRuntime.jsx(lt__default.default,{src:e.featuredImage,alt:e.featuredImageAlt??`Featured image for ${e.title}`,width:320,height:200,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"})})]})})}function zn({author:e}){return e.avatarUrl?jsxRuntime.jsx(lt__default.default,{src:e.avatarUrl,alt:e.name,width:128,height:128,className:"size-28 rounded-full border border-[var(--blog-accent-border)] object-cover sm:size-32",priority:true}):jsxRuntime.jsx("span",{className:"bg-muted text-muted-foreground inline-flex size-28 items-center justify-center rounded-full text-3xl font-semibold sm:size-32",children:Vn(e.name)})}function Vn(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 Ge=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 Xn(){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 Wn(){let e=globalThis;e.__BLOG_PLATFORM_STORAGE__||(Xn(),e.__BLOG_PLATFORM_STORAGE__=new Ge);let t=e.__BLOG_PLATFORM_STORAGE__;if(!t)throw new Error("Blog platform storage not initialized");return t}function q(){return Wn()}function ft(e){let t=globalThis;t.__BLOG_PLATFORM_STORAGE__=e;}function pe(e){let t=new Map;for(let r of e)r.author?.slug&&t.set(r.author.slug,Jt(t.get(r.author.slug),r.author));return Array.from(t.values()).sort((r,n)=>r.name.localeCompare(n.name))}function Kt(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?Jt(o,i.author):o,null);return n?{author:n,articles:r}:null}async function Kn(e,t={},r=q()){let{articles:n}=await r.listArticles({limit:t.limit??1e3,offset:t.offset??0,sortBy:"publishedAt",order:"desc"});return Kt(e,n)}function Jt(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 Jn(e){let t=e.topics??[];return t.find(r=>r.isPrimary)??t[0]??null}function ge(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 ht(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 Zn({articles:e,basePath:t="/blog",title:r="Topics",description:n="Browse articles by topic.",className:o,theme:i}){let a=E(t)||"/",c=ge(e);return jsxRuntime.jsxs("main",{style:U(i),className:h("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:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(J__default.default,{href:a,className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all articles"}),jsxRuntime.jsx("h1",{className:h("text-4xl font-light tracking-tight text-balance sm:text-5xl",G),children:r}),jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),c.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No topics have published articles yet."}):jsxRuntime.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:c.map(l=>{let u=e.filter(m=>(m.topics??[]).some(s=>s.slug===l.slug)).length;return jsxRuntime.jsxs(J__default.default,{href:S(a,`topics/${l.slug}`),className:"group rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] p-5 transition hover:border-[var(--blog-accent)] hover:no-underline",children:[jsxRuntime.jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold transition-colors",children:l.name}),l.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground mt-2 line-clamp-3 text-sm leading-relaxed",children:l.description}),jsxRuntime.jsxs("p",{className:"text-muted-foreground mt-4 text-sm",children:[u," ",u===1?"article":"articles"]})]},l.slug)})})]})}function ei({articles:e,topicSlug:t,basePath:r="/blog",className:n,theme:o}){let i=E(r)||"/",a=ht(e,t);return jsxRuntime.jsxs("main",{style:U(o),className:h("blog-topic-archive-page container mx-auto max-w-5xl px-4 py-8 sm:px-6 sm:py-12 lg:px-8 lg:py-16",n),children:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(J__default.default,{href:S(i,"topics"),className:"text-muted-foreground hover:text-[var(--blog-accent)] text-sm font-medium transition-colors",children:"Back to all topics"}),jsxRuntime.jsx("h1",{className:h("text-4xl font-light tracking-tight text-balance sm:text-5xl",G),children:a?.topic.name??"Topic not found"}),a?.topic.description&&jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:a.topic.description})]}),a?jsxRuntime.jsx("div",{className:"grid gap-5 md:grid-cols-2",children:a.articles.map(c=>jsxRuntime.jsx(ti,{article:c,topic:a.topic,basePath:i},c.id))}):jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No published articles were found for this topic."})]})}function ti({article:e,topic:t,basePath:r}){let n=S(r,e.slug),o=dateFns.formatDistanceToNow(new Date(e.publishedAt),{addSuffix:true});return jsxRuntime.jsxs(J__default.default,{href:n,className:"group overflow-hidden rounded-2xl border border-[var(--blog-accent-border)] bg-[var(--blog-card-bg)] transition hover:border-[var(--blog-accent)] hover:no-underline",children:[e.featuredImage&&jsxRuntime.jsx("div",{className:"relative aspect-[16/9] overflow-hidden",children:jsxRuntime.jsx(lt__default.default,{src:e.featuredImage,alt:e.featuredImageAlt??e.title,width:640,height:360,className:"h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"})}),jsxRuntime.jsxs("div",{className:"space-y-3 p-5",children:[jsxRuntime.jsx("span",{className:"inline-flex rounded-full border border-[var(--blog-accent-border)] px-2.5 py-1 text-xs font-medium text-[var(--blog-text-accent)]",children:t.name}),jsxRuntime.jsx("h2",{className:"group-hover:text-[var(--blog-accent)] text-xl font-semibold text-balance transition-colors",children:e.title}),e.excerpt&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:e.excerpt}),jsxRuntime.jsx("p",{className:"text-muted-foreground text-sm",children:o})]})]})}function ni({articles:e,basePath:t="/blog",title:r="Authors",description:n="Browse articles by author.",className:o,theme:i}){let a=E(t)||"/",c=pe(e);return jsxRuntime.jsxs("main",{style:U(i),className:h("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:[jsxRuntime.jsxs("header",{className:"mb-10 space-y-3 text-center",children:[jsxRuntime.jsx(J__default.default,{href:a,className:"text-muted-foreground text-sm font-medium transition-colors hover:text-[var(--blog-accent)]",children:"Back to all articles"}),jsxRuntime.jsx("h1",{className:h("text-4xl font-light tracking-tight text-balance sm:text-5xl",G),children:r}),jsxRuntime.jsx("p",{className:"text-muted-foreground mx-auto max-w-2xl text-lg text-pretty",children:n})]}),c.length===0?jsxRuntime.jsx("p",{className:"text-muted-foreground rounded-2xl border p-8 text-center",children:"No authors have published articles yet."}):jsxRuntime.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:c.map(l=>{let u=e.filter(m=>m.author?.slug===l.slug).length;return jsxRuntime.jsx(J__default.default,{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:jsxRuntime.jsxs("div",{className:"flex items-start gap-4",children:[jsxRuntime.jsx(ii,{author:l}),jsxRuntime.jsxs("div",{className:"min-w-0 space-y-2",children:[jsxRuntime.jsx("h2",{className:"text-xl font-semibold transition-colors group-hover:text-[var(--blog-accent)]",children:l.name}),l.bio&&jsxRuntime.jsx("p",{className:"text-muted-foreground line-clamp-3 text-sm leading-relaxed",children:l.bio}),jsxRuntime.jsxs("p",{className:"text-muted-foreground text-sm",children:[u," ",u===1?"article":"articles"]})]})]})},l.slug)})})]})}function ii({author:e}){let t=oi(e.name);return e.avatarUrl?jsxRuntime.jsx(lt__default.default,{src:e.avatarUrl,alt:e.name,width:56,height:56,className:"size-14 shrink-0 rounded-full border border-[var(--blog-accent-border)] object-cover"}):jsxRuntime.jsx("span",{className:"bg-muted text-muted-foreground inline-flex size-14 shrink-0 items-center justify-center rounded-full text-base font-semibold",children:t})}function oi(e){return e.trim().split(/\s+/).filter(Boolean).slice(0,2).map(r=>r[0]?.toUpperCase()).join("")||"?"}function X(e){return `sha256:${crypto.createHash("sha256").update(e).digest("hex")}`}function bt(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 Fe=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=>bt(t);hashToken(t){return X(t)}},fe=class extends Fe{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 si(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??=new ze,globalThis.__BLOG_PLATFORM_AUTH_CONFIG__}function Ve(e){globalThis.__BLOG_PLATFORM_AUTH_CONFIG__=e;}function xt(){return globalThis.__BLOG_PLATFORM_AUTH_CONFIG__??si()}function li(e){Ve(new fe(e));}async function Y(e){let t=xt(),r=t.extractToken?t.extractToken(e):bt(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 ci(e,t=""){let n=xt().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 te(e){let t=await Y(e);return t.authenticated?{authenticated:true,context:t.result.context}:{authenticated:false,error:ci(t.result)}}function ui(){let e=process.env.SKIP_BLOG_PLATFORM_AUTH;return e==="true"||e==="1"||process.env.NODE_ENV==="test"}function mi(){return globalThis.__BLOG_PLATFORM_RATE_LIMITER__??null}function pi(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.Redis({url:t,token:r}),c=new ratelimit.Ratelimit({redis:a,analytics:i,prefix:o,limiter:ratelimit.Ratelimit.slidingWindow(n,"1m")});pi(c);}function yt(){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 Zt(e){let t=mi();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 er(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 Q(e,t=""){let r=await Zt(e);return r.success?{allowed:true,rateLimitResult:r}:{allowed:false,errorResponse:er(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.
|
|
40
40
|
Example: initBlogPlatform({ auth: new EnvAuth() })
|
|
41
41
|
See https://github.com/xexr/blog-platform#authentication for more details.`);console.log("Blog platform: Setting up authentication"),Ve(t),n?(console.log("Blog platform: Using custom rate limiting configuration"),qe(n)):o?(console.log("Blog platform: Auto-configuring rate limiting from environment"),yt()):console.log("Blog platform: Rate limiting disabled"),r?(console.log("Blog platform: Using custom storage provider"),ft(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 gi(e){if(globalThis.__BLOG_PLATFORM_INITIALISED__){console.log("Blog platform: Already initialized, skipping");return}console.log("Blog platform: Initializing blog platform once"),Xe(e);}function fi(){Xe({auth:new Le,autoRateLimit:false}),console.log("Blog platform: Development mode enabled (no auth, in-memory storage, no rate limiting)");}function hi(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.`);Xe({auth:new fe(t),autoRateLimit:true}),console.log("Blog platform: Production mode enabled (environment-based auth, rate limiting)");}var T=sqliteCore.sqliteTable("bp_articles",{id:sqliteCore.text("id").primaryKey(),slug:sqliteCore.text("slug").notNull(),title:sqliteCore.text("title").notNull(),excerpt:sqliteCore.text("excerpt").notNull(),content:sqliteCore.text("content").notNull(),readingSeconds:sqliteCore.integer("reading_seconds").notNull(),wordCount:sqliteCore.integer("word_count").notNull(),publishedAt:sqliteCore.text("published_at").notNull(),updatedAt:sqliteCore.text("updated_at").notNull(),featuredImage:sqliteCore.text("featured_image"),featuredImageAlt:sqliteCore.text("featured_image_alt"),featuredImageCaption:sqliteCore.text("featured_image_caption"),featuredImageCreditText:sqliteCore.text("featured_image_credit_text"),featuredImageCreditUrl:sqliteCore.text("featured_image_credit_url"),authorJson:sqliteCore.text("author_json"),siteJson:sqliteCore.text("site_json").notNull(),metaJson:sqliteCore.text("meta_json").notNull(),version:sqliteCore.integer("version").notNull()},e=>({slugUniqueIdx:sqliteCore.uniqueIndex("bp_articles_slug_unique").on(e.slug)})),he=sqliteCore.sqliteTable("bp_operations",{key:sqliteCore.text("key").primaryKey(),resultJson:sqliteCore.text("result_json").notNull(),createdAt:sqliteCore.integer("created_at",{mode:"timestamp_ms"}).notNull(),expiresAt:sqliteCore.integer("expires_at",{mode:"timestamp_ms"})});function Pi(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 tr(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:Ai(e.metaJson),meta:wi(e.metaJson),version:e.version}}function Ai(e){return JSON.parse(e).__bloggyTopics??[]}function wi(e){let t=JSON.parse(e);return delete t.__bloggyTopics,t}var vt=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(drizzleOrm.eq(T.id,t.id)).limit(1)).length!==0)return n}else return n;let o=await this.db.select().from(T).where(drizzleOrm.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 a=Pi(t);o.length===0?await this.db.insert(T).values(a).run():await this.db.update(T).set({title:a.title,excerpt:a.excerpt,content:a.content,readingSeconds:a.readingSeconds,wordCount:a.wordCount,updatedAt:a.updatedAt,featuredImage:a.featuredImage,featuredImageAlt:a.featuredImageAlt,featuredImageCaption:a.featuredImageCaption,featuredImageCreditText:a.featuredImageCreditText,featuredImageCreditUrl:a.featuredImageCreditUrl,authorJson:a.authorJson,siteJson:a.siteJson,metaJson:a.metaJson,version:a.version}).where(drizzleOrm.and(drizzleOrm.eq(T.id,a.id),drizzleOrm.eq(T.slug,a.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(drizzleOrm.eq(T.slug,t)).limit(1);return r[0]?tr(r[0]):null}async listArticles(t={}){let{limit:r=10,offset:n=0,sortBy:o="publishedAt",order:i="desc"}=t,a=o==="publishedAt"?T.publishedAt:T.updatedAt,c=i==="desc"?drizzleOrm.desc(a):a,l=await this.db.select().from(T).orderBy(c).limit(r).offset(n),u=await this.db.select({c:drizzleOrm.sql`count(*)`}).from(T),m=Number(u?.[0]?.c??0);return {articles:l.map(tr),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(drizzleOrm.eq(T.slug,t)).limit(1)).length>0))return n}else return n;if(!(await this.db.select().from(T).where(drizzleOrm.eq(T.slug,t)).limit(1))[0]){let a={success:false,error:{code:"PUB007",message:"Article not found"},idempotencyKey:r};return await this.storeOperationResult(r,a),a}await this.db.delete(T).where(drizzleOrm.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(he).where(drizzleOrm.eq(he.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(he).where(drizzleOrm.eq(he.key,t)).run(),await this.db.insert(he).values({key:t,resultJson:JSON.stringify(r),createdAt:new Date(n),expiresAt:o?new Date(o):null}).run();}};function Si(){return {createArticles:`CREATE TABLE IF NOT EXISTS bp_articles (
|
|
42
42
|
id TEXT PRIMARY KEY,
|
|
@@ -67,6 +67,6 @@ See https://github.com/xexr/blog-platform#authentication for more details.`);con
|
|
|
67
67
|
`)});return [t,r,...o,n].join(`
|
|
68
68
|
`)}function Ei(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(a=>{let c=[];return c.push(" <sitemap>"),c.push(` <loc>${_e(a.url)}</loc>`),a.lastmod&&c.push(` <lastmod>${_e(a.lastmod)}</lastmod>`),c.push(" </sitemap>"),c.join(`
|
|
69
69
|
`)});return [r,n,...i,o].join(`
|
|
70
|
-
`)}function Oi(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&&!Di(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 H(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 Mi(e,t,r=[],n={}){return async function(){let a=(await Pt(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:be(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true)},l=ir(c);return new Response(l,{headers:{"Content-Type":"application/xml","Cache-Control":"public, max-age=3600, s-maxage=3600"}})}}function $i(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 Pt(n,o,i,e.options)]}}function _e(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function Di(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 xe={name:"@xexr/blog-platform",version:"1.0.13"};function or(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 z(){let e=or(xe.version);return {name:xe.name,version:xe.version,...e}}function re(e){try{let t=e.split(" "),r={};for(let n of t){let[o,i]=n.split("/");if(!o||!i)continue;let a=or(i),c={name:o,version:i,...a};o==="bloggy"?r.bloggyVersion=c:o==="platform"&&(r.platformVersion=c);}return r}catch{return null}}function ar(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 sr={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 Hi(){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 {...sr,enableCSP:!e,frameOptions:t??sr.frameOptions,enableHSTS:!r}}function Gi(e){return Object.entries(e).map(([t,r])=>r?`${t} ${r}`:t).join("; ")}function ji(e){return Object.entries(e).map(([t,r])=>`${t}=${r}`).join(", ")}function Fi(e,t={}){let r={...Hi(),...t},n={};if(r.enableCSP){let o={...r.cspDirectives,...t.cspDirectives??{}};n["Content-Security-Policy"]=Gi(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&&zi(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"]=ji(o);}return n}function zi(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 Fi(e,{...t,cspDirectives:{...{"default-src":"'none'","frame-ancestors":"'none'","base-uri":"'none'"},...t.cspDirectives??{}}})}var lr={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 {...lr,allowedOrigins:e?e.split(",").map(n=>n.trim()):lr.allowedOrigins,allowWildcard:t,allowCredentials:r}}function ur(e,t){return e?t.allowWildcard?true:t.allowedOrigins.includes(e):false}function dr(e,t){let r=e.headers.get("origin"),n={};return t.allowWildcard?n["Access-Control-Allow-Origin"]="*":r&&ur(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 Vi(e,t,r,n){return {...dr(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 P(e,t,r={}){let{status:n=200,headers:o={},corsConfig:i={}}=r,a={...cr(),...i},c=dr(e,a),l=We(e,a.securityConfig),u={"Content-Type":"application/json",...c,...l,...o};return server.NextResponse.json(t,{status:n,headers:u})}function Ie(e,t,r={}){let{allowedHeaders:n=qi,corsConfig:o={}}=r,i={...cr(),...o},a=e.headers.get("origin");if(a&&!i.allowWildcard&&!ur(a,i)){let u=We(e,i.securityConfig);return new server.NextResponse(null,{status:403,headers:{"Content-Type":"text/plain",...u}})}let c=Vi(e,i,[...t,"OPTIONS"],n),l=We(e,i.securityConfig);return new server.NextResponse(null,{status:200,headers:{...c,...l}})}async function Xi(e){try{let t=await Y(e);if(!t.authenticated){let p=await te(e);return P(e,p.error,{status:401})}let r=X(t.token??"anonymous"),n=await Q(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},N=$(x);return P(e,n.errorResponse,{status:429,headers:N})}if(!e.headers.get("content-type")?.includes("application/json"))return P(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 P(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let a=Wi(i);if(a.length>0)return P(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=re(c);if(p?.platformVersion){let x=z();if(p.platformVersion.major!==x.major)return P(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"),P(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(!wt(l.slug))return P(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:i.idempotencyKey},{status:400});let m=await q().saveArticle(l,i.idempotencyKey),s=z(),b=$(n.rateLimitResult),f={"X-Bloggy-Version":`platform/${s.version}`,"X-Idempotency-Key":i.idempotencyKey,...b};m.success&&(f.Location=m.url??`/${l.slug}`);let g=m.success?201:m.error?.code==="PUB003"?409:400;return P(e,m,{status:g,headers:f})}catch(t){return console.error("Publish endpoint error:",t),P(e,{success:false,error:{code:"PUB007",message:"Internal server error during publishing"},idempotencyKey:""},{status:500})}}function Wi(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 wt(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function Ji(e){try{let t=await Y(e);if(!t.authenticated){let g=await te(e);return server.NextResponse.json(g.error,{status:401})}let r=X(t.token??"anonymous"),n=await Q(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 P(e,n.errorResponse,{status:429,headers:x})}if(!e.headers.get("content-type")?.includes("application/json"))return P(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 P(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let a=Yi(i);if(a.length>0)return P(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=re(c);if(g?.platformVersion){let p=z();if(g.platformVersion.major!==p.major)return P(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(!Qi(i.slug))return P(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 q().getArticle(i.slug),x=[];return p||x.push("Article with this slug does not exist"),P(e,{success:!0,warnings:x,idempotencyKey:i.idempotencyKey},{status:200})}let u=await q().removeArticle(i.slug,i.idempotencyKey),m=z(),s=$(n.rateLimitResult),b={"X-Bloggy-Version":`platform/${m.version}`,"X-Idempotency-Key":i.idempotencyKey,...s},f=u.success?200:u.error?.code==="PUB007"?404:400;return P(e,u,{status:f,headers:b})}catch(t){return console.error("Unpublish endpoint error:",t),P(e,{success:false,error:{code:"PUB007",message:"Internal server error during unpublishing"},idempotencyKey:""},{status:500})}}function Yi(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 Qi(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function Zi(e){try{let t=await Y(e);if(!t.authenticated){let s=await te(e),b={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 P(e,b,{status:401})}let r=X(t.token??"anonymous"),n=await Q(r);if(!n.allowed){let s=n.errorResponse.error?.details?.rateLimit,b=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},f=$(b),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 P(e,g,{status:429,headers:f})}let o=z(),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("."),b=parseInt(s[0]??"0",10),f=parseInt(s[1]??"0",10),g=parseInt(s[2]?.split("-")[0]??"0",10);a={name:"bloggy",version:i,major:b,minor:f,patch:g};}else {let s=re(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=ar(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 P(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 P(e,r,{status:500})}}async function to(e,{params:t}){try{let{slug:r}=await t,n=await Y(e);if(!n.authenticated){let p=await te(e);return server.NextResponse.json(p.error,{status:401})}let o=X(n.token??"anonymous"),i=await Q(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 P(e,i.errorResponse,{status:429,headers:x})}if(!r||!wt(r))return P(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=re(a);if(p?.platformVersion){let x=z();if(p.platformVersion.major!==x.major)return P(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 q().getArticle(r)!==null,m={exists:u,...u&&{message:"Slug is already in use. Please choose another (e.g., append '-v2')."}},s=z(),b=$(i.rateLimitResult),f={"X-Bloggy-Version":`platform/${s.version}`,...b},g=e.headers.get("X-Idempotency-Key");return g&&(f["X-Idempotency-Key"]=g,console.log(`Slug check for idempotency: ${g}, exists: ${u}`)),P(e,m,{status:200,headers:f})}catch(r){return console.error("Slug existence check error:",r instanceof Error?r.message:String(r)),P(e,{exists:false,error:{code:"PUB007",message:"Internal server error during slug check"}},{status:500})}}async function ro(e){return Ie(e,["GET"])}var pl=xe.version;
|
|
70
|
+
`)}function Oi(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&&!Di(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 H(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 Mi(e,t,r=[],n={}){return async function(){let a=(await Pt(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:be(n.canonical?.domain??e.domain,n.canonical?.forceHttps??true)},l=ir(c);return new Response(l,{headers:{"Content-Type":"application/xml","Cache-Control":"public, max-age=3600, s-maxage=3600"}})}}function $i(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 Pt(n,o,i,e.options)]}}function _e(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,r=>t[r]??r)}function Di(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 xe={name:"@xexr/blog-platform",version:"1.0.14"};function or(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 z(){let e=or(xe.version);return {name:xe.name,version:xe.version,...e}}function re(e){try{let t=e.split(" "),r={};for(let n of t){let[o,i]=n.split("/");if(!o||!i)continue;let a=or(i),c={name:o,version:i,...a};o==="bloggy"?r.bloggyVersion=c:o==="platform"&&(r.platformVersion=c);}return r}catch{return null}}function ar(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 sr={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 Hi(){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 {...sr,enableCSP:!e,frameOptions:t??sr.frameOptions,enableHSTS:!r}}function Gi(e){return Object.entries(e).map(([t,r])=>r?`${t} ${r}`:t).join("; ")}function ji(e){return Object.entries(e).map(([t,r])=>`${t}=${r}`).join(", ")}function Fi(e,t={}){let r={...Hi(),...t},n={};if(r.enableCSP){let o={...r.cspDirectives,...t.cspDirectives??{}};n["Content-Security-Policy"]=Gi(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&&zi(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"]=ji(o);}return n}function zi(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 Fi(e,{...t,cspDirectives:{...{"default-src":"'none'","frame-ancestors":"'none'","base-uri":"'none'"},...t.cspDirectives??{}}})}var lr={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 {...lr,allowedOrigins:e?e.split(",").map(n=>n.trim()):lr.allowedOrigins,allowWildcard:t,allowCredentials:r}}function ur(e,t){return e?t.allowWildcard?true:t.allowedOrigins.includes(e):false}function dr(e,t){let r=e.headers.get("origin"),n={};return t.allowWildcard?n["Access-Control-Allow-Origin"]="*":r&&ur(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 Vi(e,t,r,n){return {...dr(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 P(e,t,r={}){let{status:n=200,headers:o={},corsConfig:i={}}=r,a={...cr(),...i},c=dr(e,a),l=We(e,a.securityConfig),u={"Content-Type":"application/json",...c,...l,...o};return server.NextResponse.json(t,{status:n,headers:u})}function Ie(e,t,r={}){let{allowedHeaders:n=qi,corsConfig:o={}}=r,i={...cr(),...o},a=e.headers.get("origin");if(a&&!i.allowWildcard&&!ur(a,i)){let u=We(e,i.securityConfig);return new server.NextResponse(null,{status:403,headers:{"Content-Type":"text/plain",...u}})}let c=Vi(e,i,[...t,"OPTIONS"],n),l=We(e,i.securityConfig);return new server.NextResponse(null,{status:200,headers:{...c,...l}})}async function Xi(e){try{let t=await Y(e);if(!t.authenticated){let p=await te(e);return P(e,p.error,{status:401})}let r=X(t.token??"anonymous"),n=await Q(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},N=$(x);return P(e,n.errorResponse,{status:429,headers:N})}if(!e.headers.get("content-type")?.includes("application/json"))return P(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 P(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let a=Wi(i);if(a.length>0)return P(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=re(c);if(p?.platformVersion){let x=z();if(p.platformVersion.major!==x.major)return P(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"),P(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(!wt(l.slug))return P(e,{success:!1,error:{code:"PUB002",message:"Slug can only contain lowercase letters, numbers, and hyphens"},idempotencyKey:i.idempotencyKey},{status:400});let m=await q().saveArticle(l,i.idempotencyKey),s=z(),b=$(n.rateLimitResult),f={"X-Bloggy-Version":`platform/${s.version}`,"X-Idempotency-Key":i.idempotencyKey,...b};m.success&&(f.Location=m.url??`/${l.slug}`);let g=m.success?201:m.error?.code==="PUB003"?409:400;return P(e,m,{status:g,headers:f})}catch(t){return console.error("Publish endpoint error:",t),P(e,{success:false,error:{code:"PUB007",message:"Internal server error during publishing"},idempotencyKey:""},{status:500})}}function Wi(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 wt(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function Ji(e){try{let t=await Y(e);if(!t.authenticated){let g=await te(e);return server.NextResponse.json(g.error,{status:401})}let r=X(t.token??"anonymous"),n=await Q(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 P(e,n.errorResponse,{status:429,headers:x})}if(!e.headers.get("content-type")?.includes("application/json"))return P(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 P(e,{success:!1,error:{code:"PUB001",message:"Invalid JSON in request body"},idempotencyKey:""},{status:400})}let a=Yi(i);if(a.length>0)return P(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=re(c);if(g?.platformVersion){let p=z();if(g.platformVersion.major!==p.major)return P(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(!Qi(i.slug))return P(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 q().getArticle(i.slug),x=[];return p||x.push("Article with this slug does not exist"),P(e,{success:!0,warnings:x,idempotencyKey:i.idempotencyKey},{status:200})}let u=await q().removeArticle(i.slug,i.idempotencyKey),m=z(),s=$(n.rateLimitResult),b={"X-Bloggy-Version":`platform/${m.version}`,"X-Idempotency-Key":i.idempotencyKey,...s},f=u.success?200:u.error?.code==="PUB007"?404:400;return P(e,u,{status:f,headers:b})}catch(t){return console.error("Unpublish endpoint error:",t),P(e,{success:false,error:{code:"PUB007",message:"Internal server error during unpublishing"},idempotencyKey:""},{status:500})}}function Yi(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 Qi(e){return !e||typeof e!="string"?false:/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)&&e.length>=1&&e.length<=100}async function Zi(e){try{let t=await Y(e);if(!t.authenticated){let s=await te(e),b={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 P(e,b,{status:401})}let r=X(t.token??"anonymous"),n=await Q(r);if(!n.allowed){let s=n.errorResponse.error?.details?.rateLimit,b=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},f=$(b),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 P(e,g,{status:429,headers:f})}let o=z(),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("."),b=parseInt(s[0]??"0",10),f=parseInt(s[1]??"0",10),g=parseInt(s[2]?.split("-")[0]??"0",10);a={name:"bloggy",version:i,major:b,minor:f,patch:g};}else {let s=re(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=ar(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 P(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 P(e,r,{status:500})}}async function to(e,{params:t}){try{let{slug:r}=await t,n=await Y(e);if(!n.authenticated){let p=await te(e);return server.NextResponse.json(p.error,{status:401})}let o=X(n.token??"anonymous"),i=await Q(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 P(e,i.errorResponse,{status:429,headers:x})}if(!r||!wt(r))return P(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=re(a);if(p?.platformVersion){let x=z();if(p.platformVersion.major!==x.major)return P(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 q().getArticle(r)!==null,m={exists:u,...u&&{message:"Slug is already in use. Please choose another (e.g., append '-v2')."}},s=z(),b=$(i.rateLimitResult),f={"X-Bloggy-Version":`platform/${s.version}`,...b},g=e.headers.get("X-Idempotency-Key");return g&&(f["X-Idempotency-Key"]=g,console.log(`Slug check for idempotency: ${g}, exists: ${u}`)),P(e,m,{status:200,headers:f})}catch(r){return console.error("Slug existence check error:",r instanceof Error?r.message:String(r)),P(e,{exists:false,error:{code:"PUB007",message:"Internal server error during slug check"}},{status:500})}}async function ro(e){return Ie(e,["GET"])}var pl=xe.version;
|
|
71
71
|
exports.ApiKeyAuth=Fe;exports.BlogArticlePage=Vt;exports.BlogAuthorPage=Wt;exports.BlogAuthorsIndexPage=ni;exports.BlogHomePage=Et;exports.BlogTopicArchivePage=ei;exports.BlogTopicsIndexPage=Zn;exports.Button=br;exports.Card=Se;exports.CardContent=Ne;exports.CardDescription=Zr;exports.CardFooter=en;exports.CardHeader=Yr;exports.CardTitle=Qr;exports.DrizzleStorage=vt;exports.EnvAuth=fe;exports.InMemoryStorage=Ge;exports.NEWSLETTER_SUCCESS_MESSAGE=De;exports.NewsletterSignup=Ae;exports.NoAuth=Le;exports.PACKAGE_VERSION=pl;exports.Pagination=ce;exports.PaginationContent=Ye;exports.PaginationEllipsis=Ee;exports.PaginationItem=K;exports.PaginationLink=ne;exports.PaginationNext=Ze;exports.PaginationPrevious=Qe;exports.ShadcnPagination=Je;exports.StructuredDataError=Pe;exports.UninitializedAuth=ze;exports.autoConfigureRateLimit=yt;exports.bpArticles=T;exports.bpOperations=he;exports.buildAuthorPath=k;exports.buildBlogPath=S;exports.buttonVariants=Be;exports.checkRateLimit=Zt;exports.cn=h;exports.configureRateLimit=qe;exports.createBlogSitemapRoute=Mi;exports.createDynamicBlogSitemap=$i;exports.createRateLimitErrorResponse=er;exports.createStructuredDataScript=ie;exports.createTokenFingerprint=X;exports.enforceRateLimit=Q;exports.extractKeywordsFromArticle=Rr;exports.extractTableOfContents=at;exports.extractTokenFromHeader=bt;exports.formatArticleDateMeta=ot;exports.generateArticleMetadata=Mn;exports.generateArticleStructuredData=Oe;exports.generateAuthorPageMetadata=qn;exports.generateAuthorStructuredData=Me;exports.generateBlogHomeMetadata=Xr;exports.generateBlogHomeStructuredData=it;exports.generateBlogSitemapEntries=Pt;exports.generateBreadcrumbStructuredData=Nt;exports.generateCanonicalUrl=se;exports.generateCanonicalUrlFromSlug=Ni;exports.generateCompleteArticleStructuredData=nt;exports.generateOrganizationStructuredData=tt;exports.generatePaginationMetadata=Nr;exports.generateSiteMetadata=Li;exports.generateSitemap=Bi;exports.generateSitemapIndex=Ei;exports.generateWebSiteStructuredData=rt;exports.getAllTopics=ge;exports.getArticlePrimaryTopic=Jn;exports.getAuthConfig=xt;exports.getAuthorArchive=Kt;exports.getAuthorsFromArticles=pe;exports.getBaseUrl=Ri;exports.getBlogThemeStyle=U;exports.getDrizzleAdapterSql=Si;exports.getPathPrefixFromBlogUrl=Tr;exports.getRateLimitHeaders=$;exports.getStorage=q;exports.getTopicArchive=ht;exports.initBlogPlatform=Xe;exports.initBlogPlatformDev=fi;exports.initBlogPlatformOnce=gi;exports.initBlogPlatformProd=hi;exports.initEnvAuth=li;exports.isValidCanonicalUrl=Ti;exports.loadAuthorArchive=Kn;exports.metadataToHtml=_i;exports.normalizeBlogBasePath=E;exports.normalizeDomain=be;exports.normalizeSlug=nr;exports.publishHandler=Xi;exports.safeGenerateArticleStructuredData=Cr;exports.setAuthConfig=Ve;exports.setStorage=ft;exports.shouldSkipAuth=ui;exports.sitemapToXml=ir;exports.slugExistsHandler=to;exports.slugExistsOptionsHandler=ro;exports.structuredDataToJsonLd=Rt;exports.unpublishHandler=Ji;exports.updateArticleCanonicalUrl=Ci;exports.usePagination=Sr;exports.validateMetadata=Ii;exports.validateSitemap=Oi;exports.validateStructuredData=Tt;exports.versionHandler=Zi;//# sourceMappingURL=index.js.map
|
|
72
72
|
//# sourceMappingURL=index.js.map
|