import { cache } from 'react'; import { createCmsClient } from '@kit/cms'; import { If } from '@kit/ui/if'; import { Trans } from '@kit/ui/trans'; import { createI18nServerInstance } from '~/lib/i18n/i18n.server'; import { withI18n } from '~/lib/i18n/with-i18n'; // local imports import { SitePageHeader } from '../_components/site-page-header'; import { BlogPagination } from './_components/blog-pagination'; import { PostPreview } from './_components/post-preview'; export const generateMetadata = async () => { const { t } = await createI18nServerInstance(); return { title: t('marketing:blog'), description: t('marketing:blogSubtitle'), }; }; const getContentItems = cache( async (language: string | undefined, limit: number, offset: number) => { const client = await createCmsClient(); return client.getContentItems({ collection: 'posts', limit, offset, language, sortBy: 'publishedAt', sortDirection: 'desc', }); }, ); async function BlogPage({ searchParams }: { searchParams: { page: string } }) { const { t, resolvedLanguage: language } = await createI18nServerInstance(); const page = searchParams.page ? parseInt(searchParams.page) : 0; const limit = 10; const offset = page * limit; const { total, items: posts } = await getContentItems( language, limit, offset, ); return ( <>
0} fallback={} > {posts.map((post, idx) => { return ; })}
0} />
); } export default withI18n(BlogPage); function PostsGridList({ children }: React.PropsWithChildren) { return (
{children}
); }