Added metadata
This commit is contained in:
@@ -6,6 +6,7 @@ import { getUuid } from "@/lib/hypixel/api/mojang"
|
||||
import { getPlayer } from "@/lib/hypixel/api/player"
|
||||
import { getExactLevel } from "@/lib/hypixel/general/level"
|
||||
import { Loader2Icon } from "lucide-react"
|
||||
import { Metadata } from "next"
|
||||
import { Suspense } from "react"
|
||||
import Sidebar from "./_components/Sidebar"
|
||||
import BedwarsStats from "./_stats/bedwars/bedwars"
|
||||
@@ -13,11 +14,13 @@ import DuelsStats from "./_stats/duels/duels"
|
||||
import MurderMysteryStats from "./_stats/murder-mystery/murder-mystery"
|
||||
import SkyWarsStats from "./_stats/skywars/skywars"
|
||||
|
||||
export default async function PlayerPage({
|
||||
params
|
||||
}: {
|
||||
params: Promise<{ ign: string }>
|
||||
}) {
|
||||
export async function generateMetadata({ params }: { params: Promise<{ ign: string }> }): Promise<Metadata> {
|
||||
const { ign } = await params
|
||||
const user = await getUuid(ign)
|
||||
return { title: user !== null ? user.name : "Player not found" }
|
||||
}
|
||||
|
||||
export default async function PlayerPage({ params }: { params: Promise<{ ign: string }> }) {
|
||||
const { ign } = await params
|
||||
|
||||
return (
|
||||
@@ -35,8 +38,8 @@ export default async function PlayerPage({
|
||||
}
|
||||
|
||||
async function SuspendedPage({ ign: pign }: { ign: string }) {
|
||||
const uuid = await getUuid(pign)
|
||||
if (!uuid) {
|
||||
const mc = await getUuid(pign)
|
||||
if (!mc) {
|
||||
return (
|
||||
<div className="flex flex-col items-center min-h-screen">
|
||||
<h1 className="mt-25">Player not found</h1>
|
||||
@@ -44,7 +47,7 @@ async function SuspendedPage({ ign: pign }: { ign: string }) {
|
||||
)
|
||||
}
|
||||
|
||||
const player = await getPlayer(uuid)
|
||||
const player = await getPlayer(mc.id)
|
||||
|
||||
if (!player) {
|
||||
return (
|
||||
@@ -54,7 +57,7 @@ async function SuspendedPage({ ign: pign }: { ign: string }) {
|
||||
)
|
||||
}
|
||||
|
||||
const guild = await getGuild(uuid)
|
||||
const guild = await getGuild(mc.id)
|
||||
const level = getExactLevel(player.networkExp)
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
import "./globals.css"
|
||||
|
||||
import ThemeProvider from "@/components/ThemeProvider"
|
||||
import { Toaster } from "@/components/ui/sonner"
|
||||
import type { Metadata } from "next"
|
||||
import { ReactNode } from "react"
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: {
|
||||
template: "%s | Stats Hypixel",
|
||||
default: "Stats Hypixel"
|
||||
}
|
||||
}
|
||||
|
||||
export default function RootLayout({ children }: Readonly<{ children: ReactNode }>) {
|
||||
return (
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
|
||||
@@ -18,5 +18,6 @@ export async function getUuid(ign: string) {
|
||||
|
||||
if (!parsed.success) return null
|
||||
|
||||
return parsed.data.id
|
||||
}
|
||||
return parsed.data
|
||||
}
|
||||
|
||||
|
||||
@@ -2,16 +2,16 @@ import { getUuid } from "./api/mojang"
|
||||
import { getPlayer } from "./api/player"
|
||||
|
||||
export async function _validatePlayer(ign: string) {
|
||||
const uuid = await getUuid(ign)
|
||||
const mc = await getUuid(ign)
|
||||
|
||||
if (!uuid) {
|
||||
if (!mc) {
|
||||
return {
|
||||
error: true,
|
||||
message: "Player not found"
|
||||
}
|
||||
}
|
||||
|
||||
const player = await getPlayer(uuid)
|
||||
const player = await getPlayer(mc.id)
|
||||
|
||||
if (!player) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user