The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(www): changelog frontmatter (#48249)
Francesco Sansalvadore312d05af4be0
diff --git a/apps/www/components/Changelog/ChangelogInlineMarkdown.tsx b/apps/www/components/Changelog/ChangelogInlineMarkdown.tsxnew file mode 100644index 00000000000..ccc978ecc98--- /dev/null+++ b/apps/www/components/Changelog/ChangelogInlineMarkdown.tsx@@ -0,0 +1,25 @@+import ReactMarkdown, { type Components } from 'react-markdown'+import remarkGfm from 'remark-gfm'++/**+ * Renders a changelog title/summary as inline markdown (backticks → inline code).+ * `p` and `a` are unwrapped so the output is valid inside a heading and never+ * nests an anchor (titles are already wrapped in a `<Link>`).+ */+const INLINE_COMPONENTS: Components = {+ p: ({ children }) => <>{children}</>,+ a: ({ children }) => <>{children}</>,+ code: ({ children }) => (+ <code className="bg-muted text-foreground rounded px-1 py-0.5 font-mono text-[0.85em] font-normal">+ {children}+ </code>+ ),+}++export function ChangelogInlineMarkdown({ children }: { children: string }) {+ return (+ <ReactMarkdown remarkPlugins={[remarkGfm]} components={INLINE_COMPONENTS}>+ {children}+ </ReactMarkdown>+ )+}diff --git a/apps/www/components/Changelog/ChangelogTimelineList.tsx b/apps/www/components/Changelog/ChangelogTimelineList.tsxindex a01a3490271..490fe46d0d6 100644--- a/apps/www/components/Changelog/ChangelogTimelineList.tsx+++ b/apps/www/components/Changelog/ChangelogTimelineList.tsx@@ -11,6 +11,8 @@ import Link from 'next/link'import { type MouseEvent } from 'react'import { Badge, cn } from 'ui'+import { ChangelogInlineMarkdown } from '@/components/Changelog/ChangelogInlineMarkdown'+function groupChangelogIndexByYear(items: ChangelogTimelineIndexItem[]): [number, ChangelogTimelineIndexItem[]][] {@@ -99,10 +101,16 @@ function TimelineRow({ item, href }: { item: ChangelogTimelineIndexItem; href: s<div className="border-default timeline-row-content flex min-w-0 flex-1 flex-col gap-0.5 border-b py-3"><div className="min-w-0"><Link href={href} prefetch={false} className="min-w-0 text-left">- <h3 className="text-foreground text-lg leading-snug hover:underline">{item.title}</h3>+ <h3 className="text-foreground text-lg leading-snug hover:underline [&_code]:align-middle">+ <ChangelogInlineMarkdown>{item.title}</ChangelogInlineMarkdown>+ </h3></Link></div>- {item.summary && <p className="text-foreground-lighter text-sm">{item.summary}</p>}+ {item.summary && (+ <p className="text-foreground-lighter text-sm">+ <ChangelogInlineMarkdown>{item.summary}</ChangelogInlineMarkdown>+ </p>+ )}<div className="flex min-w-0 gap-2 pt-0.5"><timedateTime={item.sortDate}diff --git a/apps/www/lib/changelog-entries-core.mjs b/apps/www/lib/changelog-entries-core.mjsindex db452741a4e..e7f8d5ed948 100644--- a/apps/www/lib/changelog-entries-core.mjs+++ b/apps/www/lib/changelog-entries-core.mjs@@ -71,6 +71,40 @@ export async function fetchChangelogEntryFilesFromTarball(return files}+/**+ * The only frontmatter fields exposed to the browser. `matter()` also parses+ * private blocks like `internal:`, and the page ships `entry.frontmatter` into+ * props — so we allowlist to keep them out of the page source. Keep in sync with+ * `ChangelogEntryFrontmatter` in `changelog-repo.ts`.+ */+export const PUBLIC_FRONTMATTER_KEYS = [+ 'title',+ 'change_type',+ 'product_stage',+ 'affected_products',+ 'affects_self_hosted',+ 'version',+ 'public',+ 'publish_date',+ 'sunset_date',+ 'learn_more_url',+ 'legacy_gh_discussion',+]++const DATE_FRONTMATTER_KEYS = new Set(['publish_date', 'sunset_date'])++/** Projects raw frontmatter to the public allowlist; date fields are stringified. */+export function toPublicFrontmatter(frontmatter) {+ const publicFrontmatter = {}+ for (const key of PUBLIC_FRONTMATTER_KEYS) {+ if (frontmatter[key] === undefined) continue+ publicFrontmatter[key] = DATE_FRONTMATTER_KEYS.has(key)+ ? toDateString(frontmatter[key])+ : frontmatter[key]+ }+ return publicFrontmatter+}+export function stripInternalBlock(body) {let sanitized = body.replace(/<!--\s*internal\s*-->[\s\S]*?<!--\s*\/internal\s*-->/gi, '')// MDX doesn't support raw HTML comments (only {/* */}) — strip any that are left@@ -105,6 +139,16 @@ function resolveDateFromFilename(filename) {return m ? `${m[1]}-${m[2]}-${m[3]}` : null}+/**+ * Coerces a frontmatter date to `YYYY-MM-DD`. An unquoted YAML date parses to a+ * JS `Date`, which breaks the string sort and can't be serialized into props.+ */+function toDateString(value) {+ if (value == null) return null+ if (value instanceof Date) return value.toISOString().slice(0, 10)+ return String(value)+}+/*** `legacy_gh_discussion-suffix` for backfilled entries* (preserves old supabase.com/changelog URLs)@@ -128,8 +172,8 @@ export function parseChangelogEntryFile(filename, raw) {return {slug: computeChangelogEntrySlug(filename, frontmatter),filename,- frontmatter,- sortDate: frontmatter.publish_date ?? resolveDateFromFilename(filename) ?? '',+ frontmatter: toPublicFrontmatter(frontmatter),+ sortDate: toDateString(frontmatter.publish_date) ?? resolveDateFromFilename(filename) ?? '',summary: extractSection(publicBody, 'Summary'),bodySection: extractSection(publicBody, 'Body', ['Migration steps']),migrationSteps: extractSection(publicBody, 'Migration steps'),diff --git a/apps/www/lib/changelog-entries-core.test.ts b/apps/www/lib/changelog-entries-core.test.tsnew file mode 100644index 00000000000..de0636c1eec--- /dev/null+++ b/apps/www/lib/changelog-entries-core.test.ts@@ -0,0 +1,119 @@+import { describe, expect, it } from 'vitest'++import {+ parseChangelogEntryFile,+ PUBLIC_FRONTMATTER_KEYS,+ toPublicFrontmatter,+} from './changelog-entries-core.mjs'++const ENTRY_WITH_INTERNAL = `---+title: Supabase Pipelines+change_type: new-feature+public: true+publish_date: 2026-01-01+affected_products:+ - pipelines+internal:+ escalation_teams:+ - team-etl+ notes: Do not ship this to the browser+reviewers:+ - alice+---++# Summary++Pipelines are here.++# Body++Long form body.+`++describe('toPublicFrontmatter', () => {+ it('keeps only allowlisted public keys', () => {+ const publicFrontmatter = toPublicFrontmatter({+ title: 'Hello',+ change_type: 'new-feature',+ internal: { escalation_teams: ['team-etl'] },+ reviewers: ['alice'],+ some_future_private_field: 'secret',+ })++ expect(publicFrontmatter).toEqual({ title: 'Hello', change_type: 'new-feature' })+ for (const key of Object.keys(publicFrontmatter)) {+ expect(PUBLIC_FRONTMATTER_KEYS).toContain(key)+ }+ })++ it('omits keys whose value is undefined', () => {+ expect(toPublicFrontmatter({ title: 'Hello', product_stage: undefined })).toEqual({+ title: 'Hello',+ })+ })++ it('normalizes Date-valued date fields to YYYY-MM-DD strings', () => {+ const publicFrontmatter = toPublicFrontmatter({+ title: 'Hello',+ publish_date: new Date('2026-05-18T00:00:00.000Z'),+ sunset_date: new Date('2026-08-05T00:00:00.000Z'),+ }) as Record<string, unknown>++ expect(publicFrontmatter.publish_date).toBe('2026-05-18')+ expect(publicFrontmatter.sunset_date).toBe('2026-08-05')+ expect(typeof publicFrontmatter.publish_date).toBe('string')+ })+})++describe('parseChangelogEntryFile', () => {+ it('never exposes the internal block on the parsed entry frontmatter', () => {+ const entry = parseChangelogEntryFile('20260101-pipelines.md', ENTRY_WITH_INTERNAL)+ // Untyped .mjs export, so `frontmatter` is inferred as {}.+ const frontmatter = entry.frontmatter as Record<string, unknown>++ expect(frontmatter.internal).toBeUndefined()+ expect(frontmatter.reviewers).toBeUndefined()+ expect(JSON.stringify(frontmatter)).not.toContain('team-etl')+ expect(JSON.stringify(frontmatter)).not.toContain('escalation_teams')++ expect(frontmatter.title).toBe('Supabase Pipelines')+ expect(frontmatter.change_type).toBe('new-feature')+ expect(frontmatter.public).toBe(true)+ expect(frontmatter.affected_products).toEqual(['pipelines'])+ })++ it('always yields a string sortDate, even for an unquoted (Date-parsed) publish_date', () => {+ const unquoted = parseChangelogEntryFile(+ '20260722-unquoted.md',+ `---\ntitle: Unquoted\nchange_type: improvement\npublic: true\npublish_date: 2026-05-18\n---\n\n# Body\n\nx\n`+ )+ expect(typeof unquoted.sortDate).toBe('string')+ expect(unquoted.sortDate).toBe('2026-05-18')++ const quoted = parseChangelogEntryFile(+ '20260722-quoted.md',+ `---\ntitle: Quoted\nchange_type: improvement\npublic: true\npublish_date: "2026-05-18"\n---\n\n# Body\n\nx\n`+ )+ expect(quoted.sortDate).toBe('2026-05-18')++ // publish_date: null falls back to the filename date, also as a string.+ const nullDate = parseChangelogEntryFile(+ '20260722-null-date.md',+ `---\ntitle: Null date\nchange_type: improvement\npublic: true\npublish_date: null\n---\n\n# Body\n\nx\n`+ )+ expect(nullDate.sortDate).toBe('2026-07-22')+ })++ it('normalizes date frontmatter reaching detail-page props, even when unquoted', () => {+ // `[slug].tsx` ships `entry.frontmatter` into props; a Date would break serialization.+ const entry = parseChangelogEntryFile(+ '20260722-unquoted-dates.md',+ `---\ntitle: Unquoted dates\nchange_type: deprecation\npublic: true\npublish_date: 2026-05-18\nsunset_date: 2026-08-05\n---\n\n# Body\n\nx\n`+ )+ const frontmatter = entry.frontmatter as Record<string, unknown>++ expect(frontmatter.publish_date).toBe('2026-05-18')+ expect(frontmatter.sunset_date).toBe('2026-08-05')+ expect(() => JSON.stringify(entry.frontmatter)).not.toThrow()+ })+})diff --git a/apps/www/lib/changelog.utils.ts b/apps/www/lib/changelog.utils.tsindex 0ed4870fffa..513f69725af 100644--- a/apps/www/lib/changelog.utils.ts+++ b/apps/www/lib/changelog.utils.ts@@ -27,6 +27,17 @@ export function toChangelogTimelineIndexItem(entry: ChangelogEntry): ChangelogTi}}+/** Strips inline markdown from a title for plain-text contexts (`<title>`, meta, Open Graph). */+export function stripTitleMarkdown(title: string) {+ return title+ .replace(/!?\[([^\]]*)\]\([^)]*\)/g, '$1') // links / images+ .replace(/(\*\*|__)(.*?)\1/g, '$2')+ .replace(/(\*|_)(.*?)\1/g, '$2')+ .replace(/~~(.*?)~~/g, '$1')+ .replace(/`+([^`]*)`+/g, '$1') // inline code+ .trim()+}+const CHANGE_TYPE_BADGE_VARIANT: Record<ChangeType,'default' | 'warning' | 'success' | 'destructive'diff --git a/apps/www/pages/changelog.tsx b/apps/www/pages/changelog.tsxindex 7a260e9664a..d91c86e625d 100644--- a/apps/www/pages/changelog.tsx+++ b/apps/www/pages/changelog.tsx@@ -12,6 +12,7 @@ import { NuqsAdapter } from 'nuqs/adapters/next/pages'import { useEffect, useMemo, useState } from 'react'import { Badge, Button, cn, IconYCombinator, Input } from 'ui'+import { ChangelogInlineMarkdown } from '@/components/Changelog/ChangelogInlineMarkdown'import { ChangelogLlmMarkdownButton } from '@/components/Changelog/ChangelogLlmMarkdownButton'import {ChangelogTimelineList,@@ -63,7 +64,6 @@ export const getServerSideProps: GetServerSideProps<PageProps> = async ({ res })const entries = await getChangelogEntries()const allIndex = entries.map(toChangelogTimelineIndexItem)const firstEntries = entries.slice(0, FEATURED_COUNT)- const restIndex = allIndex.slice(FEATURED_COUNT)// Serialized independently so one entry's MDX failure doesn't drop the others.const featuredResults = await Promise.allSettled(@@ -86,6 +86,11 @@ export const getServerSideProps: GetServerSideProps<PageProps> = async ({ res })return [result.value]})+ // Anything not successfully featured falls back to the timeline, so a featured+ // entry whose MDX failed to serialize doesn't vanish from the page.+ const featuredSlugs = new Set(featured.map((entry) => entry.slug))+ const restIndex = allIndex.filter((item) => !featuredSlugs.has(item.slug))+res.setHeader('Cache-Control', 'public, max-age=900, stale-while-revalidate=900')return { props: { featured, restIndex, allIndex } }}@@ -505,8 +510,8 @@ function ChangelogIndex({ featured, restIndex, allIndex }: PageProps) {<div className="flex w-full flex-col gap-1">{entry.title && (<Link href={`/changelog/${entry.slug}`}>- <h3 className="text-foreground text-lg hover:underline">- {entry.title}+ <h3 className="text-foreground text-lg hover:underline [&_code]:align-middle">+ <ChangelogInlineMarkdown>{entry.title}</ChangelogInlineMarkdown></h3></Link>)}diff --git a/apps/www/pages/changelog/[slug].tsx b/apps/www/pages/changelog/[slug].tsxindex 98b144d9e49..c27fd4281f2 100644--- a/apps/www/pages/changelog/[slug].tsx+++ b/apps/www/pages/changelog/[slug].tsx@@ -6,9 +6,11 @@ import Head from 'next/head'import Link from 'next/link'import { ChangelogDetailSidebar } from '@/components/Changelog/ChangelogDetailSidebar'+import { ChangelogInlineMarkdown } from '@/components/Changelog/ChangelogInlineMarkdown'import CTABanner from '@/components/CTABanner'import DefaultLayout from '@/components/Layouts/Default'import { getChangelogEntries, type ChangelogEntryFrontmatter } from '@/lib/changelog-repo'+import { stripTitleMarkdown } from '@/lib/changelog.utils'import mdxComponents from '@/lib/mdx/mdxComponents'import { mdxSerialize } from '@/lib/mdx/mdxSerialize'@@ -20,61 +22,66 @@ type PageProps = {source: MDXRemoteSerializeResult}-const ChangelogDetailPage = ({ title, created_at, slug, frontmatter, source }: PageProps) => (- <>- <Head>- <link rel="alternate" type="text/markdown" href={`/changelog/${slug}.md`} />- </Head>- <NextSeo- title={`${title} · Changelog`}- description={title}- openGraph={{- title,- url: `https://supabase.com/changelog/${slug}`,- type: 'article',- }}- />- <DefaultLayout>- <div className="container mx-auto max-w-5xl px-4 py-10 sm:px-16 xl:px-20">- <nav- aria-label="Breadcrumb"- className="text-foreground-lighter mb-6 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm"- >- <Link href="/changelog" className="text-foreground-lighter hover:underline">- Changelog- </Link>- </nav>- <header className="border-default mb-8 flex flex-col gap-2 border-b pb-6">- <h1 className="h1 text-2xl sm:text-3xl">{title}</h1>- <div className="flex items-center gap-2">- <p className="text-foreground-lighter font-mono text-xs">- {dayjs(created_at).format('MMM D, YYYY')}- </p>- </div>- </header>-- <div className="grid grid-cols-1 gap-8 lg:grid-cols-12 lg:gap-10 mb-8 lg:mb-20">- <div className="min-w-0 lg:col-span-8">- <article className="prose prose-docs max-w-none wrap-break-word [&>*:first-child:not(style):not(script)]:mt-0 [&>style:first-child+*]:mt-0 [&>script:first-child+*]:mt-0 [&>*:last-child:not(style):not(script)]:mb-0">- {'error' in source ? (- <p>Error rendering changelog entry: {source.error.message}</p>- ) : (- <MDXClient {...source} components={mdxComponents('blog')} />- )}- </article>- </div>+const ChangelogDetailPage = ({ title, created_at, slug, frontmatter, source }: PageProps) => {+ const plainTitle = stripTitleMarkdown(title)+ return (+ <>+ <Head>+ <link rel="alternate" type="text/markdown" href={`/changelog/${slug}.md`} />+ </Head>+ <NextSeo+ title={`${plainTitle} · Changelog`}+ description={plainTitle}+ openGraph={{+ title: plainTitle,+ url: `https://supabase.com/changelog/${slug}`,+ type: 'article',+ }}+ />+ <DefaultLayout>+ <div className="container mx-auto max-w-5xl px-4 py-10 sm:px-16 xl:px-20">+ <nav+ aria-label="Breadcrumb"+ className="text-foreground-lighter mb-6 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm"+ >+ <Link href="/changelog" className="text-foreground-lighter hover:underline">+ Changelog+ </Link>+ </nav>+ <header className="border-default mb-8 flex flex-col gap-2 border-b pb-6">+ <h1 className="h1 text-2xl sm:text-3xl [&_code]:align-middle">+ <ChangelogInlineMarkdown>{title}</ChangelogInlineMarkdown>+ </h1>+ <div className="flex items-center gap-2">+ <p className="text-foreground-lighter font-mono text-xs">+ {dayjs(created_at).format('MMM D, YYYY')}+ </p>+ </div>+ </header>- <aside className="border-default border-t pt-6 lg:col-span-4 lg:border-t-0 lg:pl-4 lg:pt-0">- <div className="thin-scrollbar lg:sticky lg:top-24 lg:max-h-[calc(100vh-8rem)] lg:overflow-y-auto">- <ChangelogDetailSidebar slug={slug} frontmatter={frontmatter} />+ <div className="grid grid-cols-1 gap-8 lg:grid-cols-12 lg:gap-10 mb-8 lg:mb-20">+ <div className="min-w-0 lg:col-span-8">+ <article className="prose prose-docs max-w-none wrap-break-word [&>*:first-child:not(style):not(script)]:mt-0 [&>style:first-child+*]:mt-0 [&>script:first-child+*]:mt-0 [&>*:last-child:not(style):not(script)]:mb-0">+ {'error' in source ? (+ <p>Error rendering changelog entry: {source.error.message}</p>+ ) : (+ <MDXClient {...source} components={mdxComponents('blog')} />+ )}+ </article></div>- </aside>++ <aside className="border-default border-t pt-6 lg:col-span-4 lg:border-t-0 lg:pl-4 lg:pt-0">+ <div className="thin-scrollbar lg:sticky lg:top-24 lg:max-h-[calc(100vh-8rem)] lg:overflow-y-auto">+ <ChangelogDetailSidebar slug={slug} frontmatter={frontmatter} />+ </div>+ </aside>+ </div></div>- </div>- <CTABanner />- </DefaultLayout>- </>-)+ <CTABanner />+ </DefaultLayout>+ </>+ )+}export const getStaticPaths: GetStaticPaths = async () => {return { paths: [], fallback: 'blocking' }@@ -86,7 +93,9 @@ export const getStaticProps: GetStaticProps<PageProps> = async ({ params }) => {const entries = await getChangelogEntries()const entry = entries.find((e) => e.slug === slug)- if (!entry) return { notFound: true }+ // `revalidate` on notFound too, else Next.js caches the 404 forever — an entry+ // requested before it went live would keep 404ing after publish.+ if (!entry) return { notFound: true, revalidate: 900 }const source = await mdxSerialize(entry.bodySection)