Skip to content

Commit

Permalink
🔄 refactor generateMetadata and CategoryLayout to improve type defini…
Browse files Browse the repository at this point in the history
…tions and simplify props structure
  • Loading branch information
damien-schneider committed Dec 13, 2024
1 parent f3b09d2 commit 8880d7b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
20 changes: 6 additions & 14 deletions apps/website/src/app/(site)/[section]/[category]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Metadata> {
};

export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { section: sectionParam, category: categoryParam } = await params;
const section = findSectionBySlug(sectionParam);
if (!section) {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion apps/website/src/app/(site)/[section]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ type Props = {
children: ReactNode;
params: Promise<{
section: string;
category: string;
}>;
};

Expand Down

0 comments on commit 8880d7b

Please sign in to comment.