Next.JS project failed to deploy "Type error: Layout "app/(platform)/(dashboard)/board/[boardId]/layout.tsx" does not match the required types of a Next.js Layout. "generateMetaData" is not a valid Layout export field." #123840
Unanswered
youssefash97
asked this question in
Programming Help
Replies: 1 comment
-
I suggest you to read the dynamic routes in NextJs documentation. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Body
I tried to deploy a NextJs project and it works fine when i tested it but when i tried to deploy it on Vercel it gave me this error in image
My code:
`import { db } from "@/lib/db";
import { auth } from "@clerk/nextjs";
import { notFound, redirect } from "next/navigation";
import { BoardNavbar } from "./_components/board-navbar";
export async function generateMetaData({
params,
}: {
params: { boardId: string };
}) {
const { orgId } = auth();
if (!orgId) {
return {
title: "Board",
};
}
const board = await db.board.findUnique({
where: {
id: params.boardId,
orgId,
},
});
return {
title: board?.title || "Board",
};
}
const BoardIdLayout = async ({
children,
params,
}: {
children: React.ReactNode;
params: { boardId: string };
}) => {
const { orgId } = auth();
if (!orgId) {
redirect("/select-org");
}
const board = await db.board.findUnique({
where: {
id: params.boardId,
orgId,
},
});
if (!board) {
notFound();
}
return (
<div
className="relative h-full bg-no-repeat bg-cover"
style={{ backgroundImage:
url(${board.imageFullUrl})
}}>
{children}
);
};
export default BoardIdLayout;
`
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions