feat(web): render cms pages and navigation from db

This commit is contained in:
2026-02-12 19:58:01 +01:00
parent 281b1d7a1b
commit f65a9ea03f
11 changed files with 273 additions and 75 deletions

View File

@@ -1,19 +1,11 @@
"use client"
import { useTranslations } from "next-intl"
import { listPublicNavigation } from "@cms/db"
import { Link } from "@/i18n/navigation"
import { LanguageSwitcher } from "./language-switcher"
export function PublicSiteHeader() {
const t = useTranslations("Layout")
const navItems = [
{ href: "/", label: t("nav.home") },
{ href: "/about", label: t("nav.about") },
{ href: "/contact", label: t("nav.contact") },
]
export async function PublicSiteHeader() {
const navItems = await listPublicNavigation("header")
return (
<header className="border-b border-neutral-200 bg-white/80 backdrop-blur">
@@ -22,19 +14,28 @@ export function PublicSiteHeader() {
href="/"
className="text-sm font-semibold uppercase tracking-[0.2em] text-neutral-700"
>
{t("brand")}
CMS Web
</Link>
<nav className="flex flex-wrap items-center gap-2">
{navItems.map((item) => (
{navItems.length === 0 ? (
<Link
key={item.href}
href={item.href}
href="/"
className="rounded-md border border-neutral-300 px-3 py-1.5 text-sm font-medium text-neutral-700 hover:bg-neutral-100"
>
{item.label}
Home
</Link>
))}
) : (
navItems.map((item) => (
<Link
key={item.id}
href={item.href}
className="rounded-md border border-neutral-300 px-3 py-1.5 text-sm font-medium text-neutral-700 hover:bg-neutral-100"
>
{item.label}
</Link>
))
)}
</nav>
<LanguageSwitcher />