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.
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import Link from "next/link";
|
|
import { excerpt } from "@/lib/format";
|
|
import { prisma } from "@/lib/prisma";
|
|
import { siteSettings } from "@/lib/services/site-settings";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export default async function HomePage() {
|
|
const [hotelName, articles] = await Promise.all([
|
|
siteSettings.get("hotel_name", "Atom"),
|
|
prisma.websiteArticles.findMany({
|
|
orderBy: { createdAt: "desc" },
|
|
take: 4,
|
|
}),
|
|
]);
|
|
|
|
return (
|
|
<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>
|
|
);
|
|
}
|