export default async function Product({
params,
}: {
params: { slug: string | undefined };
}) {
// uri to get single Product from backend
const filteredData = pagedata.filter((elem) => elem.title == params.slug);
const pageElems = filteredData[0].content.map((elem) => {
return (
<div
key={elem.title}
className={`${satoshi.className} inner-elements-company-page`}
id={elem.title.replaceAll(" ", "_")}
>
<h3>{elem.title}</h3>
<p>{elem.desc}</p>
</div>
);
});
return (
<>
<Header />
<div className="total-company-page-component">
<div className="total-company-heading-container">
<h1 className={integralCFBold.className}>{params.slug}</h1>
</div>
<div className="total-company-details-container">{pageElems}</div>
</div>
<Footer />
</>
);
}
export async function getStaticPaths() {
const paths = pagedata.map((Elem: { title: { toString: () => any } }) => {
return {
params: {
slug: Elem.title.toString(),
},
};
});
return {
paths,
fallback: false,
};
}
This is my Code. I tried to getstatic paths by using data in pagedata. Please provide a possible fix . The app runs good in localhost without any error. But the Build command throws the error
Type error: Type 'OmitWithTag<typeof import("D:/Fullstack/e-commerce/frontend-copy/src/app/footer/[slug]/page"), "metadata" | "default" | "config" | "generateStaticParams" | "revalidate" | "dynamic" | "dynamicParams" | ... 4 more ... | "generateMetadata", "">' does not satisfy the constraint '{ [x: string]: never; }'. Property 'getStaticPaths' is incompatible with index signature. Type '() => Promise<{ paths: { params: { slug: any; }; }[]; fallback: boolean; }>' is not assignable to type 'never'.
6 | 7 | // Check that the entry is a valid entry
8 | checkFields<Diff<{ | ^ 9 | default: Function 10 | config?: {} 11 | generateStaticParams?: Function
This is the Error msg I am getting when I try npm run build command Please provide me with the posiible fix.