feat: news page is centered

This commit is contained in:
Ivan Rezchikov
2026-07-17 12:14:25 +03:00
parent 15f3429de9
commit e957879212
2 changed files with 25 additions and 14 deletions
+24 -14
View File
@@ -14,6 +14,7 @@ import { getNavLinkByPageId } from "@/lib/navlinks/repository";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { Metadata } from "next"; import { Metadata } from "next";
import { getImageUrl } from "@/lib/image"; import { getImageUrl } from "@/lib/image";
import { Badge } from "@/components/ui/badge";
function makeDescription(text?: string, maxLength = 160) { function makeDescription(text?: string, maxLength = 160) {
if (!text) return undefined; if (!text) return undefined;
@@ -127,7 +128,7 @@ function BlockRenderer({ block }: { block: Block }) {
case "CALLOUT": case "CALLOUT":
return ( return (
<Alert className="md:w-max"> <Alert className="max-w-xl">
<InfoIcon /> <InfoIcon />
<AlertTitle>{b.title}</AlertTitle> <AlertTitle>{b.title}</AlertTitle>
<AlertDescription>{b.text}</AlertDescription> <AlertDescription>{b.text}</AlertDescription>
@@ -200,8 +201,8 @@ function BlockRenderer({ block }: { block: Block }) {
return <Separator />; return <Separator />;
case "LINK": case "LINK":
return <Link href={b.href} target="_blank"> return <Link href={b.href} className="w-max " target="_blank">
<Button variant="secondary" className="max-w-full">{b.label}</Button> <Button variant="secondary">{b.label}</Button>
</Link> </Link>
default: default:
@@ -249,6 +250,8 @@ export default async function Page({ params }: { params: Promise<{ type: string;
user?.isAdmin && wasUpdatedByOther && updatedBy user?.isAdmin && wasUpdatedByOther && updatedBy
? `${updatedBy.firstName} ${updatedBy.secondName}` ? `${updatedBy.firstName} ${updatedBy.secondName}`
: null, : null,
tags: isNews ? page.meta.tags : null,
}; };
return ( return (
@@ -273,18 +276,25 @@ export default async function Page({ params }: { params: Promise<{ type: string;
{meta.author && <p className="flex gap-1.5 items-center"><UserIcon size={16} />{meta.author}</p>} {meta.author && <p className="flex gap-1.5 items-center"><UserIcon size={16} />{meta.author}</p>}
{meta.updatedBy && <p className="flex gap-1.5 items-center"><UserIcon size={16} />Last update by {meta.updatedBy}</p>} {meta.updatedBy && <p className="flex gap-1.5 items-center"><UserIcon size={16} />Last update by {meta.updatedBy}</p>}
</div> </div>
{isNews && (<div className="flex flex-row gap-4">
{((meta as PageMeta)?.tags)?.map((tag) => (
<Badge key={tag}>{tag}</Badge>
))}
</div>)}
</div> </div>
<div className="flex flex-col gap-6"> <div className={cn(isNews && `max-w-2xl mx-auto`)}>
{isArchived && ( <div className="flex flex-col gap-6 [&>a+a]:-my-2.5">
<Alert className="md:w-max"> {isArchived && (
<InfoIcon /> <Alert className="md:w-max">
<AlertTitle>This page is archived</AlertTitle> <InfoIcon />
<AlertDescription>It can be seen only by administrators. Make any edits to make it visible again.</AlertDescription> <AlertTitle>This page is archived</AlertTitle>
</Alert> <AlertDescription>It can be seen only by administrators. Make any edits to make it visible again.</AlertDescription>
)} </Alert>
{resolvedBlocks.map((block) => ( )}
<BlockRenderer key={block.id} block={block} /> {resolvedBlocks.map((block) => (
))} <BlockRenderer key={block.id} block={block} />
))}
</div>
</div> </div>
</div> </div>
); );
+1
View File
@@ -1,6 +1,7 @@
import { NewsCard } from "@/components/news-card"; import { NewsCard } from "@/components/news-card";
import { getPages } from "@/lib/pages/repository"; import { getPages } from "@/lib/pages/repository";
import { ArrowRightIcon } from "lucide-react"; import { ArrowRightIcon } from "lucide-react";
import Image from "next/image";
import Link from "next/link"; import Link from "next/link";
export default async function Home() { export default async function Home() {