feat: news

This commit is contained in:
Ivan Rezchikov
2026-06-20 18:30:39 +03:00
parent 674fd11aa9
commit 95fd6ae716
19 changed files with 886 additions and 159 deletions
+19 -16
View File
@@ -3,7 +3,9 @@ import Header from "@/components/header";
import { Badge } from "@/components/ui/badge"
import { getPages } from "@/lib/pages/repository";
import { PageMeta } from "@/lib/pages/types";
import { formatDate } from "@/lib/utils";
import { ArrowRight, Calendar, Globe2 } from "lucide-react";
import Link from "next/link";
export default async function Home() {
const news = await getPages("NEWS", "PUBLISHED", 5);
@@ -36,24 +38,25 @@ export default async function Home() {
</div>
<div className="flex flex-col gap-8 mt-8">
<h1 className="underline underline-offset-8 decoration-2">Recent news</h1>
{
news.length > 0 ? news.map((n) => (
<div className="flex flex-col gap-2" key={n.id}>
<h2 className="w-max hover:underline underline-offset-8 decoration-2 duration-200 cursor-pointer">{n.title}</h2>
<div className="flex flex-row gap-8 items-center">
<h3 className="flex gap-2 items-baseline"><Calendar size={18} />{(n.publishedAt)?.toString()}</h3>
<h3 className="flex gap-2 items-baseline"><Globe2 size={18} />{(n.meta as PageMeta)?.location}</h3>
<div className="flex flex-row gap-4">
{((n.meta as PageMeta)?.tags)?.map((i, tag) => (
<Badge key={i}>{tag}</Badge>
))}
<div className="flex flex-col gap-6">
{
news.length > 0 ? news.map((n) => (
<div className="flex flex-col gap-2" key={n.id}>
<Link href={`/news/${n.slug}`}><h2 className="w-max hover:underline underline-offset-8 decoration-2 duration-200 cursor-pointer">{n.title}</h2></Link>
<div className="flex flex-row gap-8 items-center">
<h3 className="flex gap-2 items-baseline"><Calendar size={18} />{formatDate(n.publishedAt)}</h3>
<h3 className="flex gap-2 items-baseline"><Globe2 size={18} />{(n.meta as PageMeta)?.location}</h3>
<div className="flex flex-row gap-4">
{((n.meta as PageMeta)?.tags)?.map((tag) => (
<Badge key={tag}>{tag}</Badge>
))}
</div>
</div>
</div>
</div>
), (
<h2 className="w-max flex flex-row items-center gap-2 hover:gap-4 hover:underline underline-offset-8 decoration-2 duration-200 cursor-pointer">See all news<ArrowRight size={32} /></h2>
)) : <h2>There are no news yet...</h2>
}
)) : <h2>There are no news yet...</h2>
}
</div>
<Link href="/news"><h2 className="w-max flex flex-row items-center gap-2 hover:gap-4 hover:underline underline-offset-8 decoration-2 duration-200 cursor-pointer">See all news<ArrowRight size={32} /></h2></Link>
</div>
</div>
<Footer />