import { getPublishedArticles, getTagList } from '@/lib/queries'; import ArticleCard from '@/components/ArticleCard'; import { InFeedAd, SidebarAd } from '@/components/ads/placements'; import Link from 'next/link'; import { env } from '@/lib/env'; export const dynamic = 'force-dynamic'; export default async function HomePage({ searchParams, }: { searchParams: { page?: string }; }) { const page = Math.max(1, parseInt(searchParams.page ?? '1', 10) || 1); const PER = 21; const [articles, tags] = await Promise.all([ getPublishedArticles('top-stories', PER, (page - 1) * PER), getTagList(12), ]); const hero = articles[0]; const rest = articles.slice(1); return ( <>
{/* Main column */}
{hero ? (
{hero.image ? ( // eslint-disable-next-line @next/next/no-img-element ) : (
{env.siteName}
)}
Lead briefing

{hero.headline ?? hero.title}

{hero.excerpt}

) : ( )} {rest.length > 0 && (
{interleaveInFeedAds(rest, 3).map((node) => node)}
)}
{/* Sidebar */}
); } import type { ReactNode } from 'react'; /** Interleave an InFeedAd after every `every`th card. */ function interleaveInFeedAds( cards: Awaited>, every: number, ): ReactNode[] { const out: ReactNode[] = []; cards.forEach((card, i) => { out.push(); if ((i + 1) % every === 0) out.push(); }); return out; } function EmptyState() { return (

No briefings yet

The ingestion worker has not published anything yet. Trigger your first run (see the README “First run” section) and this page will fill with synthesized briefings.

); }