import type { Metadata } from 'next' import Link from 'next/link' import { notFound } from 'next/navigation' import { formatDate, type ThemeRouteContext } from 'ampless' import { ampless } from '@/lib/ampless' import { LightboxBinder } from '@/components/lightbox-content' import { TagList } from '@/components/tag-list' import { SiteHeader } from '@/components/site-chrome/site-header' import { SiteSidebar } from '@/components/site-chrome/site-sidebar' import { SiteFooter } from '@/components/site-chrome/site-footer' import { CollapsibleSidebar } from '@/components/site-chrome/collapsible-sidebar' type PostCtx = ThemeRouteContext<{ slug: string }> export async function generatePostMetadata({ params }: PostCtx): Promise { const { slug } = await params const post = await ampless.getPublishedPost(slug) if (!post) return {} return ampless.postMetadata(post) } // Docs post page: sidebar always visible while reading. The sidebar // re-uses theme.sidebarNav, so navigation context stays consistent // across the home page and individual articles. export default async function DocsPost({ params }: PostCtx) { const { slug } = await params const [post, settings, theme] = await Promise.all([ ampless.getPublishedPost(slug), ampless.loadSiteSettings(), ampless.loadThemeConfig(), ]) if (!post) notFound() const postBody = await ampless.publicBodyForPost(post) const html = await ampless.publicHtmlForPost(post) const defaultLightbox = settings.media.imageDisplay === 'lightbox' const maxWidth = settings.media.imageMaxWidth ?? '100%' const proseStyle: React.CSSProperties = { ['--ampless-img-max-width' as string]: maxWidth, } return ( <>

{post.title}

{post.publishedAt && ( )}
{postBody} {html.beforeContent}
{await ampless.renderBody(post)}
{html.afterContent} {await ampless.publicPostScriptsForPage([post])}
© {new Date().getFullYear()} {settings.site.name} } /> ) }