Fix naming for server platform in embeds
All checks were successful
Deploy Frontend / docker (17, 3.8.5) (push) Successful in 1m10s

This commit is contained in:
Braydon 2024-04-17 23:52:48 -04:00
parent a20b8008f4
commit 7c9ba6d151
3 changed files with 15 additions and 5 deletions

@ -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,
});

@ -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) => (
<SelectItem key={index} value={platform}>
{platform.charAt(0).toUpperCase() +
platform.substring(1)}
{capitialize(platform)}
</SelectItem>
)
)}

@ -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);
};