From 00096552cee8c81ed5d9588ce29d70898d68a59e Mon Sep 17 00:00:00 2001 From: trafficlunar Date: Fri, 16 May 2025 19:45:21 +0100 Subject: [PATCH] feat: change metadata when tags are present in index page --- src/app/layout.tsx | 2 +- src/app/page.tsx | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 4bdb936..0cbe434 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -15,7 +15,7 @@ const lexend = Lexend({ export const metadata: Metadata = { metadataBase: new URL(process.env.BASE_URL!), - title: "TomodachiShare — home for Tomodachi Life Miis!", + title: "TomodachiShare - home for Tomodachi Life Miis!", description: "Discover and share Mii residents for your Tomodachi Life island!", keywords: ["mii", "tomodachi life", "nintendo", "tomodachishare", "tomodachi-share", "mii creator", "mii collection"], category: "Gaming", diff --git a/src/app/page.tsx b/src/app/page.tsx index 55a6d44..1b3eae8 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -5,11 +5,33 @@ import { auth } from "@/lib/auth"; import MiiList from "@/components/mii-list"; import Skeleton from "@/components/mii-list/skeleton"; +import { Metadata } from "next"; interface Props { searchParams: Promise<{ [key: string]: string | string[] | undefined }>; } +export async function generateMetadata({ searchParams }: Props): Promise { + const { tags } = await searchParams; + + if (!tags) return {}; + + const description = `Discover Miis tagged ${tags} for your Tomodachi Life island!`; + + return { + metadataBase: new URL(process.env.BASE_URL!), + title: `Miis tagged with '${tags}' - TomodachiShare`, + description, + keywords: [...tags, "mii", "tomodachi life", "nintendo", "tomodachishare", "tomodachi-share", "mii creator", "mii collection"], + openGraph: { + description, + }, + twitter: { + description, + }, + }; +} + export default async function Page({ searchParams }: Props) { const session = await auth();