Fix params/searchParams types for Next.js app router
This commit is contained in:
@@ -6,7 +6,7 @@ import Footer from "@/components/marketing/Footer";
|
|||||||
import ScrollReveal from "@/components/animations/ScrollReveal";
|
import ScrollReveal from "@/components/animations/ScrollReveal";
|
||||||
import { getBlogPost, getBlogPosts, getSiteConfig } from "@/lib/content";
|
import { getBlogPost, getBlogPosts, getSiteConfig } from "@/lib/content";
|
||||||
|
|
||||||
type Props = { params: { slug: string } };
|
type Props = { params: Promise<{ slug: string }> };
|
||||||
|
|
||||||
// Corps des articles — FUTURE: champ rich text Payload CMS
|
// Corps des articles — FUTURE: champ rich text Payload CMS
|
||||||
const articleContenu: Record<string, string[]> = {
|
const articleContenu: Record<string, string[]> = {
|
||||||
@@ -69,7 +69,7 @@ export async function generateStaticParams() {
|
|||||||
export async function generateMetadata(
|
export async function generateMetadata(
|
||||||
{ params }: Props
|
{ params }: Props
|
||||||
): Promise<Metadata> {
|
): Promise<Metadata> {
|
||||||
const { slug } = params;
|
const { slug } = await params;
|
||||||
const [post, config] = await Promise.all([getBlogPost(slug), getSiteConfig()]);
|
const [post, config] = await Promise.all([getBlogPost(slug), getSiteConfig()]);
|
||||||
if (!post) return { title: "Article introuvable" };
|
if (!post) return { title: "Article introuvable" };
|
||||||
return {
|
return {
|
||||||
@@ -80,7 +80,7 @@ export async function generateMetadata(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default async function BlogArticlePage({ params }: Props) {
|
export default async function BlogArticlePage({ params }: Props) {
|
||||||
const { slug } = params;
|
const { slug } = await params;
|
||||||
const post = await getBlogPost(slug);
|
const post = await getBlogPost(slug);
|
||||||
if (!post) notFound();
|
if (!post) notFound();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user