feat: list of pages

This commit is contained in:
Ivan Rezchikov
2026-07-13 20:11:42 +03:00
parent 2e356e4c47
commit 7a7ca2d831
7 changed files with 122 additions and 68 deletions
-2
View File
@@ -141,8 +141,6 @@ function BlockRenderer({ block }: { block: Block }) {
<img
src={b.url}
alt={b.caption || "Image"}
width={1200}
height={800}
style={imageWidth && imageWidth < 100 ? { width: `${imageWidth}%` } : undefined}
className={cn(
"h-auto rounded-md border object-contain",
-33
View File
@@ -1,33 +0,0 @@
import { NewsCard } from "@/components/news-card";
import { getPages } from "@/lib/pages/repository";
import { PAGE_TYPES, PageType } from "@/lib/pages/types";
import { getCurrentUser } from "@/lib/user";
import { Metadata } from "next";
import { notFound, redirect } from "next/navigation";
export const metadata: Metadata = { title: "Pages" };
export default async function Pages({ params }: { params: Promise<{ type: string }> }) {
const user = await getCurrentUser();
if (!user?.isAdmin) redirect("/");
const { type } = await params;
if (!PAGE_TYPES.includes(type as PageType)) {
notFound();
}
const pages = await getPages(type as PageType, "PUBLISHED");
return (
<div className="flex flex-col p-4 md:p-16 gap-8 md:gap-16 mb-4 md:mb-0">
<h2>All pages of type ${type}</h2>
<div className="flex flex-col gap-6">
{
pages.length > 0 ? pages.map((n) => (
<NewsCard news={n} key={n.id} />
)) : <h2 className="text-muted-foreground">There are no pages of that type yet...</h2>
}
</div>
</div>
);
}