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 ServerSearch from "@/components/server/server-search";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { minecrafter } from "@/font/fonts"; import { minecrafter } from "@/font/fonts";
import { capitialize } from "@/lib/stringUtils";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { PageProps } from "@/types/page"; import { PageProps } from "@/types/page";
import { ExclamationCircleIcon } from "@heroicons/react/24/outline"; import { ExclamationCircleIcon } from "@heroicons/react/24/outline";
@ -94,15 +95,14 @@ export const generateMetadata = async ({
// Try and get the server to display // Try and get the server to display
if (platform && hostname) { if (platform && hostname) {
try { try {
const serverPlatform: ServerPlatform = platform as ServerPlatform;
const server: const server:
| CachedJavaMinecraftServer | CachedJavaMinecraftServer
| CachedBedrockMinecraftServer = await getMinecraftServer( | CachedBedrockMinecraftServer = await getMinecraftServer(
serverPlatform, platform as ServerPlatform,
hostname hostname
); // Get the server to embed ); // Get the server to embed
return 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.`, 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, thumbnail: (server as CachedJavaMinecraftServer).favicon?.url,
}); });

@ -9,6 +9,7 @@ import {
SelectTrigger, SelectTrigger,
SelectValue, SelectValue,
} from "@/components/ui/select"; } from "@/components/ui/select";
import { capitialize } from "@/lib/stringUtils";
import { redirect } from "next/navigation"; import { redirect } from "next/navigation";
import { ReactElement } from "react"; import { ReactElement } from "react";
import { ServerPlatform } from "restfulmc-lib"; import { ServerPlatform } from "restfulmc-lib";
@ -63,8 +64,7 @@ const ServerSearch = ({
{Object.values(ServerPlatform).map( {Object.values(ServerPlatform).map(
(platform, index) => ( (platform, index) => (
<SelectItem key={index} value={platform}> <SelectItem key={index} value={platform}>
{platform.charAt(0).toUpperCase() + {capitialize(platform)}
platform.substring(1)}
</SelectItem> </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);
};