fix: fix titles for non-existent documentation pages
Some checks failed
Deploy Next.js application / deploy (push) Failing after 5s
Some checks failed
Deploy Next.js application / deploy (push) Failing after 5s
This commit is contained in:
parent
cb9a35cb2b
commit
54cff67b7e
1 changed files with 22 additions and 0 deletions
|
@ -28,6 +28,28 @@ export async function generateMetadata({ params }) {
|
||||||
docLink.href ==
|
docLink.href ==
|
||||||
`/docs${obtainedParams.slug ? "/" + obtainedParams.slug.join("/") : ""}`
|
`/docs${obtainedParams.slug ? "/" + obtainedParams.slug.join("/") : ""}`
|
||||||
);
|
);
|
||||||
|
try {
|
||||||
|
await fs.readFile(
|
||||||
|
`${process.cwd()}/docs/${obtainedParams.slug ? obtainedParams.slug.join("/") : ""}.md`
|
||||||
|
);
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
} catch (err) {
|
||||||
|
try {
|
||||||
|
await fs.readFile(
|
||||||
|
`${process.cwd()}/docs/${obtainedParams.slug ? obtainedParams.slug.join("/") : ""}/index.md`
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
return {
|
||||||
|
title: "404 Not Found - MERNMail",
|
||||||
|
openGraph: {
|
||||||
|
title: "404 Not Found - MERNMail"
|
||||||
|
},
|
||||||
|
twitter: {
|
||||||
|
title: "404 Not Found - MERNMail"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
title: `${foundDocLink ? foundDocLink.label : obtainedParams.slug && obtainedParams.slug.length > 0 ? obtainedParams.slug[obtainedParams.slug.length - 1] : "Documentation"} - MERNMail`,
|
title: `${foundDocLink ? foundDocLink.label : obtainedParams.slug && obtainedParams.slug.length > 0 ? obtainedParams.slug[obtainedParams.slug.length - 1] : "Documentation"} - MERNMail`,
|
||||||
description:
|
description:
|
||||||
|
|
Loading…
Reference in a new issue