Updated title
This commit is contained in:
@@ -5,11 +5,31 @@ import { getUuid } from "@/lib/hypixel/api/mojang"
|
|||||||
import { Guild } from "@/lib/schema/guild"
|
import { Guild } from "@/lib/schema/guild"
|
||||||
import { cn, parseSearchParams } from "@/lib/utils"
|
import { cn, parseSearchParams } from "@/lib/utils"
|
||||||
import { Loader2Icon, ShieldAlert } from "lucide-react"
|
import { Loader2Icon, ShieldAlert } from "lucide-react"
|
||||||
|
import { Metadata } from "next"
|
||||||
import { ReactNode, Suspense } from "react"
|
import { ReactNode, Suspense } from "react"
|
||||||
import z from "zod"
|
import z from "zod"
|
||||||
import { GuildPageLoadText } from "./_client"
|
import { GuildPageLoadText } from "./_client"
|
||||||
import Sidebar from "./_components/sidebar"
|
import Sidebar from "./_components/sidebar"
|
||||||
|
|
||||||
|
export async function generateMetadata({ params, searchParams }: PageProps<"/guild/[value]">): Promise<Metadata> {
|
||||||
|
const { value } = await params
|
||||||
|
const ptype = parseSearchParams(await searchParams).getValue("type")
|
||||||
|
const { data: type } = z.literal("id").or(z.literal("name")).or(z.literal("player")).default("player").safeParse(ptype)
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case "id":
|
||||||
|
case "name":
|
||||||
|
const g = await getGuild(value, type)
|
||||||
|
return { title: g?.name !== undefined ? `${g.name} Guild` : "Unknown" }
|
||||||
|
case "player":
|
||||||
|
case undefined:
|
||||||
|
const p = await getUuid(value)
|
||||||
|
return { title: p !== null ? `${p.name}'s Guild` : "Player not in Guild" }
|
||||||
|
default:
|
||||||
|
throw new Error(`Unknown type: ${type satisfies never}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function GuildPage({ params, searchParams }: PageProps<"/guild/[value]">) {
|
export default function GuildPage({ params, searchParams }: PageProps<"/guild/[value]">) {
|
||||||
const maintenance = env.MAINTENANCE_MODE
|
const maintenance = env.MAINTENANCE_MODE
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import z from "zod"
|
|||||||
import { PlayerPageLoadText, PlayerStats } from "./_client"
|
import { PlayerPageLoadText, PlayerStats } from "./_client"
|
||||||
import Sidebar from "./_components/sidebar"
|
import Sidebar from "./_components/sidebar"
|
||||||
|
|
||||||
export async function generateMetadata({ params }: { params: Promise<{ ign: string }> }): Promise<Metadata> {
|
export async function generateMetadata({ params }: PageProps<"/player/[ign]">): Promise<Metadata> {
|
||||||
const { ign } = await params
|
const { ign } = await params
|
||||||
const user = await getUuid(ign)
|
const user = await getUuid(ign)
|
||||||
return { title: user !== null ? `${user.name}'s Stats` : "Player not found" }
|
return { title: user !== null ? `${user.name}'s Stats` : "Player not found" }
|
||||||
|
|||||||
Reference in New Issue
Block a user