diff --git a/Frontend/src/app/(pages)/server/[[...slug]]/page.tsx b/Frontend/src/app/(pages)/server/[[...slug]]/page.tsx index 5738633..8b2793b 100644 --- a/Frontend/src/app/(pages)/server/[[...slug]]/page.tsx +++ b/Frontend/src/app/(pages)/server/[[...slug]]/page.tsx @@ -3,6 +3,7 @@ import ServerResult from "@/components/server/server-result"; import ServerSearch from "@/components/server/server-search"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { minecrafter } from "@/font/fonts"; +import { capitialize } from "@/lib/stringUtils"; import { cn } from "@/lib/utils"; import { PageProps } from "@/types/page"; import { ExclamationCircleIcon } from "@heroicons/react/24/outline"; @@ -94,15 +95,14 @@ export const generateMetadata = async ({ // Try and get the server to display if (platform && hostname) { try { - const serverPlatform: ServerPlatform = platform as ServerPlatform; const server: | CachedJavaMinecraftServer | CachedBedrockMinecraftServer = await getMinecraftServer( - serverPlatform, + platform as ServerPlatform, hostname ); // Get the server to embed return Embed({ - title: `${serverPlatform} Server: ${server.hostname}`, + title: `${capitialize(platform)} Server: ${server.hostname}`, description: `There are ${server.players.online}/${server.players.max} playing here!\n\nClick to view data about this server.`, thumbnail: (server as CachedJavaMinecraftServer).favicon?.url, }); diff --git a/Frontend/src/app/components/server/server-search.tsx b/Frontend/src/app/components/server/server-search.tsx index ad00fe6..ba445bd 100644 --- a/Frontend/src/app/components/server/server-search.tsx +++ b/Frontend/src/app/components/server/server-search.tsx @@ -9,6 +9,7 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; +import { capitialize } from "@/lib/stringUtils"; import { redirect } from "next/navigation"; import { ReactElement } from "react"; import { ServerPlatform } from "restfulmc-lib"; @@ -63,8 +64,7 @@ const ServerSearch = ({ {Object.values(ServerPlatform).map( (platform, index) => ( - {platform.charAt(0).toUpperCase() + - platform.substring(1)} + {capitialize(platform)} ) )} diff --git a/Frontend/src/app/lib/stringUtils.ts b/Frontend/src/app/lib/stringUtils.ts new file mode 100644 index 0000000..4c47c6a --- /dev/null +++ b/Frontend/src/app/lib/stringUtils.ts @@ -0,0 +1,10 @@ +/** + * Capitalize the first + * character in the given input. + * + * @param input the input to capitalize + * @returns the capitalized input + */ +export const capitialize = (input: string): string => { + return input.charAt(0).toUpperCase() + input.slice(1); +};