Next.js Discord

Discord Forum

Failed to compile on vercel

Answered
Dwarf Crocodile posted this in #help-forum
Open in Discord
Original message was deleted.
Answered by Yi Lon Ma
-params:{slug:string[]}
+params:Promise<{slug:string[]}>
View full answer

3 Replies

Dwarf Crocodile
if you need code for src/app/(dashboard)/components/[...slug]/page.tsx:

import { Mdx } from "@/components/mdx-components/Mdx";
import { cn } from "@/lib/utils";
import { allDocs } from "contentlayer/generated";
import { notFound } from "next/navigation";

interface CompSlugPageProps {
  params: {
    slug: string[];
  };
}

async function getDocFromParams(slug: string[]) {
  const doc = allDocs.find((doc) => doc.slugAsParams === slug.join("/"));

  if (!doc) {
    notFound();
  }

  return doc;
}

export default async function CompSlugPage({ params }: CompSlugPageProps) {
  const doc = await getDocFromParams(params.slug);

  return (
    <div className="min-h-screen bg-white/5 text-white flex items-center justify-center">
      <div className="flex flex-col gap-3">
        <h1 className={cn("scroll-m-20 text-3xl font-gilroy tracking-tight")}>
          {doc.title}
        </h1>

        {doc.description && (
          <p className="text-[15px] text-muted-foreground text-balance">
            {doc.description}
          </p>
        )}

        <Mdx code={doc.body.code} />
      </div>
    </div>
  );
}
-params:{slug:string[]}
+params:Promise<{slug:string[]}>
Answer
@Dwarf Crocodile pls mark solution next time instead of deleting the question tks