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 { getBlogPost, getBlogPosts, getSiteConfig } from "@/lib/content";
|
||||
|
||||
type Props = { params: Promise<{ slug: string }> };
|
||||
type Props = { params: { slug: string } };
|
||||
|
||||
// Corps des articles — FUTURE: champ rich text Payload CMS
|
||||
const articleContenu: Record<string, string[]> = {
|
||||
@@ -66,8 +66,10 @@ export async function generateStaticParams() {
|
||||
return posts.map((p) => ({ slug: p.slug }));
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
const { slug } = await params;
|
||||
export async function generateMetadata(
|
||||
{ params }: Props
|
||||
): Promise<Metadata> {
|
||||
const { slug } = params;
|
||||
const [post, config] = await Promise.all([getBlogPost(slug), getSiteConfig()]);
|
||||
if (!post) return { title: "Article introuvable" };
|
||||
return {
|
||||
@@ -78,7 +80,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
}
|
||||
|
||||
export default async function BlogArticlePage({ params }: Props) {
|
||||
const { slug } = await params;
|
||||
const { slug } = params;
|
||||
const post = await getBlogPost(slug);
|
||||
if (!post) notFound();
|
||||
|
||||
@@ -91,7 +93,10 @@ export default async function BlogArticlePage({ params }: Props) {
|
||||
<section className="bg-navy py-12 md:py-16">
|
||||
<div className="max-w-3xl mx-auto px-4 sm:px-6">
|
||||
<ScrollReveal direction="up">
|
||||
<Link href="/blog" className="inline-flex items-center gap-1.5 text-white/50 hover:text-white text-sm mb-6 transition-colors">
|
||||
<Link
|
||||
href="/blog"
|
||||
className="inline-flex items-center gap-1.5 text-white/50 hover:text-white text-sm mb-6 transition-colors"
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 19l-7-7 7-7" />
|
||||
</svg>
|
||||
|
||||
Reference in New Issue
Block a user