From 8880d7b7546fcdef8353b425e3e5584bb25eaca7 Mon Sep 17 00:00:00 2001 From: Damien Schneider <74979845+damien-schneider@users.noreply.github.com> Date: Fri, 13 Dec 2024 05:23:24 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=84=20refactor=20generateMetadata=20an?= =?UTF-8?q?d=20CategoryLayout=20to=20improve=20type=20definitions=20and=20?= =?UTF-8?q?simplify=20props=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../(site)/[section]/[category]/layout.tsx | 20 ++++++------------- .../src/app/(site)/[section]/layout.tsx | 1 - 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/apps/website/src/app/(site)/[section]/[category]/layout.tsx b/apps/website/src/app/(site)/[section]/[category]/layout.tsx index 77f53ae..a546d06 100644 --- a/apps/website/src/app/(site)/[section]/[category]/layout.tsx +++ b/apps/website/src/app/(site)/[section]/[category]/layout.tsx @@ -7,14 +7,15 @@ import { NEXT_PUBLIC_SITE_URL } from "#/src/lib/site.const"; import { findCategoryBySlug } from "#/src/utils/section-category-components-utils/find-category-by-slug"; import { findSectionBySlug } from "#/src/utils/section-category-components-utils/find-section-by-slug"; -export async function generateMetadata({ - params, -}: { +type Props = { + children: JSX.Element; params: Promise<{ section: string; category: string; }>; -}): Promise { +}; + +export async function generateMetadata({ params }: Props): Promise { const { section: sectionParam, category: categoryParam } = await params; const section = findSectionBySlug(sectionParam); if (!section) { @@ -58,16 +59,7 @@ export async function generateMetadata({ return {}; } -export default async function CategoryLayout({ - params, - children, -}: { - children: JSX.Element; - params: Promise<{ - section: string; - category: string; - }>; -}) { +export default async function CategoryLayout({ params, children }: Props) { const { section: sectionParam, category: categoryParam } = await params; const sectionInList = findSectionBySlug(sectionParam); diff --git a/apps/website/src/app/(site)/[section]/layout.tsx b/apps/website/src/app/(site)/[section]/layout.tsx index 4de5e0a..017e772 100644 --- a/apps/website/src/app/(site)/[section]/layout.tsx +++ b/apps/website/src/app/(site)/[section]/layout.tsx @@ -10,7 +10,6 @@ type Props = { children: ReactNode; params: Promise<{ section: string; - category: string; }>; };