Add data-driven public pages (home, news, profile)

Real App Router pages reading the converted Prisma models:
- home: latest 4 articles (websiteArticles) + hotel_name from settings
- /news + /news/[slug]: article index and detail
- /u/[username]: profile (avatar via imager helper, motto, rank, credits, online)
- shared SiteNav (reads session via auth() + hotel_name), globals.css
- src/lib/format.ts: avatarImageUrl + excerpt helpers (unit-tested)

Verified: tsc exit 0, vitest 43/43, next build exit 0 (7 routes). Pages render
against a live DB (deferred until DATABASE_URL is provided). i18n to be layered
on next.
This commit is contained in:
Simo committed 2026-06-27 16:42:59 +02:00
1 parent 8fca407f0f
commit 6e34d485d4
9 files changed
+327 -7

No files matched your search

+33 -6
View File
@@ -1,17 +1,44 @@
import Link from "next/link";
import { excerpt } from "@/lib/format";
import { prisma } from "@/lib/prisma";
import { siteSettings } from "@/lib/services/site-settings";
// Reads settings from the DB at request time — never at build.
export const dynamic = "force-dynamic";
export default async function HomePage() {
const hotelName = (await siteSettings.get("hotel_name", "Atom")) ?? "Atom";
const [hotelName, articles] = await Promise.all([
siteSettings.get("hotel_name", "Atom"),
prisma.websiteArticles.findMany({
orderBy: { createdAt: "desc" },
take: 4,
}),
]);
return (
<main style={{ fontFamily: "system-ui", padding: "2rem", maxWidth: 640 }}>
<h1>Welcome to {hotelName}</h1>
<p>AtomCMS → Next.js conversion. Foundation, full Prisma schema and auth core are in place.</p>
<Link href="/login">Login →</Link>
<main>
<h1>Welcome to {hotelName ?? "Atom"}</h1>
<p className="muted">AtomCMS → Next.js. Reading live data through the converted Prisma schema.</p>
<h2>Latest news</h2>
{articles.length === 0 ? (
<p className="muted">No articles yet.</p>
) : (
<div className="grid cols-2">
{articles.map((a) => (
<article key={a.slug} className="card" style={{ padding: 0, overflow: "hidden" }}>
{a.image ? <img className="article-img" src={a.image} alt="" /> : null}
<div style={{ padding: "0.9rem 1.1rem" }}>
<h3 style={{ margin: "0 0 0.3rem" }}>
<Link href={`/news/${a.slug}`}>{a.title}</Link>
</h3>
<p className="muted" style={{ margin: 0 }}>
{excerpt(a.shortStory, 120)}
</p>
</div>
</article>
))}
</div>
)}
</main>
);
}