import { useBreakpoint } from 'common' import dayjs from 'dayjs' import { GitCommit, ListFilter, Rss, X } from 'lucide-react' import type { GetServerSideProps } from 'next' import { MDXClient } from 'next-mdx-remote-client/csr' import type { SerializeResult as MDXRemoteSerializeResult } from 'next-mdx-remote-client/serialize' import { NextSeo } from 'next-seo' import Head from 'next/head' import Link from 'next/link' import { parseAsArrayOf, parseAsString, useQueryState } from 'nuqs' 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, ChangeTypeBadge, } from '@/components/Changelog/ChangelogTimelineList' import CTABanner from '@/components/CTABanner' import DefaultLayout from '@/components/Layouts/Default' import { getChangelogEntries, type ChangeType } from '@/lib/changelog-repo' import { CHANGE_TYPE_DISPLAY, CHANGE_TYPES, CHANGELOG_PRODUCT_STAGES, CHANGELOG_PRODUCT_TAGS, CHANGELOG_SELF_HOSTED_OPTIONS, changelogTagFilterUrl, isChangelogChangeType, isChangelogProductSlug, isChangelogProductStageSlug, isChangelogSelfHostedSlug, itemMatchesChangelogSearch, itemMatchesChangelogSelectedSelfHosted, itemMatchesChangelogSelectedStages, itemMatchesChangelogSelectedTags, itemMatchesChangelogSelectedTypes, stripTitleMarkdown, toChangelogTimelineIndexItem, type ChangelogTimelineIndexItem, } from '@/lib/changelog.utils' import { breadcrumbListSchema, collectionPageSchema, serializeJsonLd } from '@/lib/json-ld' import mdxComponents from '@/lib/mdx/mdxComponents' import { mdxSerialize } from '@/lib/mdx/mdxSerialize' const FEATURED_COUNT = 3 const TITLE = 'Changelog' const DESCRIPTION = 'New updates and improvements to Supabase' const CHANGELOG_URL = 'https://supabase.com/changelog' type FeaturedEntry = { slug: string title: string created_at: string source: MDXRemoteSerializeResult changeType: ChangelogTimelineIndexItem['changeType'] affectedProducts: string[] } type PageProps = { featured: FeaturedEntry[] restIndex: ChangelogTimelineIndexItem[] allIndex: ChangelogTimelineIndexItem[] } export const getServerSideProps: GetServerSideProps = async ({ res }) => { const entries = await getChangelogEntries() const allIndex = entries.map(toChangelogTimelineIndexItem) const firstEntries = entries.slice(0, FEATURED_COUNT) // Serialized independently so one entry's MDX failure doesn't drop the others. const featuredResults = await Promise.allSettled( firstEntries.map(async (entry): Promise => ({ slug: entry.slug, title: entry.frontmatter.title, created_at: entry.sortDate, source: await mdxSerialize(entry.bodySection), changeType: entry.frontmatter.change_type, affectedProducts: entry.frontmatter.affected_products ?? [], })) ) const featured = featuredResults.flatMap((result) => { if (result.status === 'rejected') { console.error(result.reason) return [] } 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 } } } export default function ChangelogPage(props: PageProps) { const collectionJsonLd = collectionPageSchema({ url: CHANGELOG_URL, name: TITLE, description: DESCRIPTION, items: props.allIndex.map((item) => ({ url: `https://supabase.com/changelog/${item.slug}`, name: stripTitleMarkdown(item.title), })), }) const breadcrumbJsonLd = breadcrumbListSchema([ { name: 'Home', url: 'https://supabase.com' }, { name: TITLE, url: CHANGELOG_URL }, ]) return ( <>