import { getTranslations } from 'next-intl/server'; import { cn } from '@crux-kit/utils'; import { getWebRuntimeAPI } from '#web-runtime/api/web-runtime-api'; import { MediaImage } from '#web-runtime/components/media-image'; import type { PageDocument, PageSearchParams, PageTeaser, PageTeaserPagination } from '#web-runtime/types'; import { toPublicHref } from '#i18n/content-href'; import { Button } from '#shared/ui/Button'; import { pagerPages, requestedPage } from './blog-pager'; import Breadcrumbs from './Breadcrumbs'; import PageHero from './PageHero'; const POSTS_PER_PAGE = 12; function PostCard({ post, locale, readMoreLabel }: { post: PageTeaser; locale: string; readMoreLabel: string; }) { const href = toPublicHref(`/${locale}/${post.path}`); const publishedAt = post.publishedAt ? new Date(post.publishedAt) : null; return (
{post.media ? ( ) : (
); } function Pager({ pagination, basePath, labels }: { pagination: PageTeaserPagination; basePath: string; labels: { pagination: string; previous: string; next: string }; }) { if (pagination.lastPage <= 1) { return null; } const pageHref = (page: number) => (page <= 1 ? basePath : `${basePath}?page=${page}`); const controlClassName = 'size-11 p-0'; const pages = pagerPages(pagination.page, pagination.lastPage); return ( ); } export default async function BlogPageLayout({ page, searchParams }: { page: PageDocument; searchParams?: PageSearchParams; }) { const t = await getTranslations('Pages.BlogPage'); const { items: posts, pagination } = await getWebRuntimeAPI().listBlogPosts({ locale: page.locale, page: requestedPage(searchParams), perPage: POSTS_PER_PAGE }); return (
{posts.length === 0 ? (

{t('empty')}

) : (
{posts.map((post) => ( ))}
)}
); }