Website/src/components/ServerStatus.svelte

19 Zeilen
765 B
Svelte

2023-11-03 20:31:27 +01:00
<script lang="ts">
import { t } from "astro-i18n"
import {server} from "./stores/server.ts";
function generateVersionString(version: string): string {
let versions = version.split(" ").slice(1)
return `${versions[0].replace(",", "")} - ${versions[versions.length - 1]}`
}
</script>
{#await $server}
<p>{t("status.loading")}</p>
{:then data}
<h2>{t("status.status")}: <span class="text-green-500">{t("status.online")}</span></h2>
<h2>{t("status.players", { count: `${data.players.online}/${data.players.max}`})}</h2>
<h2>{t("status.version", { version: generateVersionString(data.version.name)})}</h2>
{:catch error}
<h1>{t("status.status")}: <span class="text-red-500">{t("status.offline")}</span></h1>
{/await}