import type { Metadata } from "next" import { ObfuscatedAddress } from "@/components/obfuscated-address" import { ObfuscatedEmail } from "@/components/obfuscated-email" import { drupal } from "@/lib/drupal" const drupalBaseUrl = process.env.NEXT_PUBLIC_DRUPAL_BASE_URL ?? "" export const dynamic = "force-dynamic" export const metadata: Metadata = { title: "Imprint", description: "Legal notice and imprint for nasarek.dev", } const FALLBACK_TITLE = "Imprint" const BODY_STYLES = "[&_h2]:mb-4 [&_h2]:mt-8 [&_h2]:text-xl [&_h2]:font-semibold [&_h2]:text-slate-900 [&_p]:mb-4 [&_p]:text-slate-700 [&_a]:text-emerald-600 [&_a]:underline hover:[&_a]:text-emerald-500" /** * Splits the CMS body HTML at {address} and {email} placeholders and renders * the obfuscated components in their place so bots cannot harvest the data. */ function ImprintBody({ html }: { html: string }) { const parts = html.split(/(

\{(?:address|email)\}<\/p>)/g) return (

{parts.map((part, i) => { if (part === "

{address}

") return if (part === "

{email}

") return

if (!part) return null return
})}
) } async function getImprintPageContent(): Promise<{ title: string body: string | null }> { if (!drupalBaseUrl) { return { title: FALLBACK_TITLE, body: null, } } try { const translatedPath = await drupal.translatePath("/imprint", { withAuth: true, next: { revalidate: 60 }, }) if (!translatedPath?.jsonapi?.resourceName || !translatedPath?.entity?.uuid) { return { title: FALLBACK_TITLE, body: null } } const resourceType = translatedPath.jsonapi.resourceName const raw = await drupal.getResource( resourceType, translatedPath.entity.uuid, { withAuth: true, next: { revalidate: 60 }, deserialize: false } ) const rawData = (raw as { data?: Record })?.data if (!rawData) { return { title: FALLBACK_TITLE, body: null } } const title = (rawData.title as string) ?? FALLBACK_TITLE const bodyObj = rawData.body const bodyText = typeof bodyObj === "string" ? bodyObj : (bodyObj as { processed?: string; value?: string })?.processed ?? (bodyObj as { processed?: string; value?: string })?.value ?? "" return { title, body: bodyText || null, } } catch (error) { if ((error as Error).name !== "AbortError") { console.warn("[Imprint] CMS unreachable:", (error as Error).message) } return { title: FALLBACK_TITLE, body: null } } } export default async function ImprintPage() { const { title, body } = await getImprintPageContent() return (

{title}

{body && }
) }