Update server page theme color
Some checks failed
Deploy Frontend / docker (17, 3.8.5) (push) Has been cancelled

This commit is contained in:
Braydon 2024-04-20 15:20:21 -04:00
parent 9e60a7d8c5
commit 7afd38bcc2
3 changed files with 2 additions and 21 deletions

Binary file not shown.

@ -29,7 +29,6 @@
"class-variance-authority": "^0.7.0",
"clipboard-copy": "^4.0.1",
"clsx": "^2.1.0",
"fast-average-color": "^9.4.0",
"lucide-react": "^0.372.0",
"next": "14.2.2",
"next-plausible": "^3.12.0",

@ -16,7 +16,6 @@ import {
type RestfulMCAPIError,
ServerPlatform,
} from "restfulmc-lib";
import { FastAverageColor, FastAverageColorResult } from "fast-average-color";
/**
* The page to lookup a server.
@ -144,25 +143,8 @@ export const generateViewport = async ({
const hostname: string | undefined = params.slug?.[1]; // The hostname of the server to search for
if (platform && hostname) {
try {
const server:
| CachedJavaMinecraftServer
| CachedBedrockMinecraftServer = await getMinecraftServer(
platform as ServerPlatform,
hostname
); // Get the server to embed
let color: string = "#55FF55";
// Get the average color of the server favicon
if (platform == ServerPlatform.JAVA) {
const averageColor: FastAverageColorResult =
await new FastAverageColor().getColorAsync(
(server as CachedJavaMinecraftServer).favicon?.url || ""
);
color = averageColor.hex;
}
return { themeColor: color }; // Online
await getMinecraftServer(platform as ServerPlatform, hostname); // Get the server to embed
return { themeColor: "#55FF55" }; // Online
} catch (err) {
return { themeColor: "#AA0000" }; // Error
}