From cffc2808b5ef4780ebce27a0531963ac0ec0f88a Mon Sep 17 00:00:00 2001 From: achmad Date: Thu, 28 May 2026 22:30:17 +0700 Subject: [PATCH] feat: ArticleGrid and Homepage --- app/page.tsx | 125 +++++++------------------------- components/home/ArticleGrid.tsx | 29 ++++++++ 2 files changed, 56 insertions(+), 98 deletions(-) create mode 100644 components/home/ArticleGrid.tsx diff --git a/app/page.tsx b/app/page.tsx index 433c8aa..f81d55e 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,101 +1,30 @@ -import Image from "next/image"; +import { getSiteSettings, getArticles } from '@/lib/directus' +import HeroSection from '@/components/home/HeroSection' +import ArticleGrid from '@/components/home/ArticleGrid' + +export const revalidate = false + +export default async function HomePage() { + let heroArticle = null + let latestArticles: import('@/lib/types').Article[] = [] + + try { + const [settings, articles] = await Promise.all([ + getSiteSettings(), + getArticles({ limit: 12 }), + ]) + heroArticle = settings.hero_article + latestArticles = settings.hero_article + ? articles.filter((a) => a.id !== settings.hero_article!.id) + : articles + } catch { + // Directus not available yet + } -export default function Home() { return ( -
-
- Next.js logo -
    -
  1. - Get started by editing{" "} - - app/page.tsx - - . -
  2. -
  3. Save and see your changes instantly.
  4. -
- -
- - Vercel logomark - Deploy now - - - Read our docs - -
-
- -
- ); + <> + {heroArticle && } + + + ) } diff --git a/components/home/ArticleGrid.tsx b/components/home/ArticleGrid.tsx new file mode 100644 index 0000000..9f0c3a1 --- /dev/null +++ b/components/home/ArticleGrid.tsx @@ -0,0 +1,29 @@ +import ArticleCard from '@/components/article/ArticleCard' +import type { Article } from '@/lib/types' + +interface Props { + articles: Article[] + title?: string +} + +export default function ArticleGrid({ articles, title }: Props) { + if (articles.length === 0) return null + + return ( +
+ {title && ( +
+

+ {title} +

+
+
+ )} +
+ {articles.map((article) => ( + + ))} +
+
+ ) +}