update embed
Some checks failed
Deploy App / docker (ubuntu-latest) (push) Has been cancelled

This commit is contained in:
Lee 2024-04-16 22:55:45 +01:00
parent 7ad9987cd1
commit 70a95cc6ce

@ -1,6 +1,7 @@
import { Card } from "@/app/components/card";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/app/components/ui/table";
import { generateEmbed } from "@/common/embed";
import { capitalizeFirstLetter } from "@/common/string-utils";
import { cn } from "@/common/utils";
import { getMojangEndpointStatus } from "mcutils-library";
import { CachedEndpointStatus } from "mcutils-library/dist/types/cache/cachedEndpointStatus";
@ -26,6 +27,16 @@ function getColor(status: any): string {
}
}
/**
* Formats the status
*
* @param status the status of the endpoint
* @returns the formatted status
*/
function formatStatus(status: any): string {
return capitalizeFirstLetter(status.toLowerCase());
}
async function getData(): Promise<CachedEndpointStatus> {
const status = await getMojangEndpointStatus();
return status;
@ -36,7 +47,7 @@ export async function generateMetadata(): Promise<Metadata> {
const description = Object.entries(endpoints)
.map(([url, status]) => {
return `${url}: ${status}`;
return `**${url}**: ${formatStatus(status)}`;
})
.join("\n");
@ -75,7 +86,9 @@ export default async function Page(): Promise<JSX.Element> {
{url}
</Link>
</TableCell>
<TableCell className={cn(getColor(status), "p-[0.3rem] text-center")}>{status}</TableCell>
<TableCell className={cn(getColor(status), "p-[0.3rem] text-center")}>
{formatStatus(status)}
</TableCell>
</TableRow>
);
})}