44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import React from 'react';
|
|
import type { Metadata } from 'next';
|
|
import * as Util from "node:util";
|
|
import {fetchBlogPosts} from "../../../lib/contentful/blogPosts";
|
|
import {unstable_setRequestLocale} from "next-intl/server";
|
|
import Link from "next/link";
|
|
import {fetchBlogPostCategories} from "../../../lib/contentful/blogPostsCategories";
|
|
import {CustomPagination} from "../../../components/view/CustomPagination";
|
|
import {DEFAULT_PAGE_SIZE} from "../../../constants/common";
|
|
import {BlogPosts} from "../../../components/BlogPosts/BlogPosts";
|
|
|
|
|
|
interface BlogPostPageParams {
|
|
slug: string
|
|
}
|
|
|
|
interface BlogPostPageProps {
|
|
params: BlogPostPageParams
|
|
}
|
|
|
|
export async function generateStaticParams(): Promise<BlogPostPageParams[]> {
|
|
const blogPosts = await fetchBlogPosts({ preview: false })
|
|
|
|
return blogPosts.data.map((post) => ({ slug: post.slug }))
|
|
}
|
|
|
|
|
|
export default async function Blog({ params: { locale }, searchParams }: { params: { locale: string }, searhParams?: {page: number} }) {
|
|
unstable_setRequestLocale(locale);
|
|
const pageSize = DEFAULT_PAGE_SIZE
|
|
const page = searchParams.page || undefined
|
|
// BlogPosts('/'+locale+'/blog/', locale, pageSize)
|
|
return (
|
|
|
|
<BlogPosts
|
|
basePath={'/'+locale+'/blog/'}
|
|
locale={locale}
|
|
pageSize={pageSize}
|
|
page={page}
|
|
>
|
|
</BlogPosts>
|
|
);
|
|
}
|