carpa_turborepo/apps/web-astro/src/pages/[locale]/[slug].astro

22 lines
752 B
Plaintext

---
import Base from "../../layouts/Base.astro";
import { isLocale } from "../../lib/locale";
import { getPage, richTextToPlain } from "../../lib/payload";
const { locale, slug } = Astro.params;
if (!isLocale(locale) || !slug) return new Response(null, { status: 404 });
const page = await getPage(slug, locale).catch(() => null);
if (!page) return new Response(null, { status: 404 });
const body = richTextToPlain(page.content);
---
<Base title={`${page.title} · Carpa`} locale={locale}>
<article class="prose max-w-none">
<h1 class="text-4xl font-bold">{page.title}</h1>
{page.excerpt && <p class="lead text-lg opacity-70">{page.excerpt}</p>}
<div class="mt-6 whitespace-pre-line leading-relaxed">{body}</div>
</article>
</Base>