From ee2588913907cdb8d591fa25501367e9c6050cef Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Mon, 14 Oct 2024 00:42:15 -0400 Subject: [PATCH] small bug fix Took 8 minutes --- src/app/[[...slug]]/page.tsx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/app/[[...slug]]/page.tsx b/src/app/[[...slug]]/page.tsx index 490f145..a4535e4 100644 --- a/src/app/[[...slug]]/page.tsx +++ b/src/app/[[...slug]]/page.tsx @@ -100,18 +100,19 @@ export const generateMetadata = async ({ }): Promise => { const slug: string = (((await params).slug as string[]) || undefined)?.join( "/" - ); // The slug of the content + ); if (slug) { - const content: DocsContentMetadata | undefined = ( - await getDocsContent() - ).find( - (metadata: DocsContentMetadata): boolean => metadata.slug === slug - ); // Get the content based on the provided slug - if (content) { + const pages: DocsContentMetadata[] = await getDocsContent(); + const decodedSlug: string = decodeURIComponent(slug || ""); + const page: DocsContentMetadata | undefined = pages.find( + (metadata: DocsContentMetadata): boolean => + metadata.slug === (decodedSlug || pages[0].slug) + ); + if (page) { return Embed({ - title: content.title, - description: content.summary, - thumbnail: config.ogApiUrl.replace("{title}", content.title), + title: page.title, + description: page.summary, + thumbnail: config.ogApiUrl.replace("{title}", page.title), }); } }