diff --git a/src/components/EloTable.svelte b/src/components/EloTable.svelte
index 20552d7..e772715 100644
--- a/src/components/EloTable.svelte
+++ b/src/components/EloTable.svelte
@@ -23,6 +23,8 @@
export let gamemode: string;
+ export let topFive: boolean = false;
+
let request = getRequest();
function getRequest() {
@@ -33,6 +35,7 @@
{#await request}
Loading...
{:then data}
+ {@const topFiveData = data.slice(0, 5)}
@@ -43,7 +46,7 @@
- {#each data as player, i (player.name)}
+ {#each (topFive ? topFiveData : data) as player, i (player.name)}
{`${i + 1}.`} |
{player.name} |
diff --git a/src/components/admin/pages/Edit.svelte b/src/components/admin/pages/Edit.svelte
index 687e2a6..6212dfb 100644
--- a/src/components/admin/pages/Edit.svelte
+++ b/src/components/admin/pages/Edit.svelte
@@ -42,20 +42,31 @@
value: branch
}));
- async function createBranch() {
- const name = prompt("Branch name:");
- if (name) {
- selected = null;
- await $pageRepo.createBranch(name);
- let inter = setInterval(() => {
- branches.reload();
- if ($branches.includes(name)) {
- selectedBranch = name;
- searchValue = "";
- clearInterval(inter);
+ async function createBranch(name: string | null = null): Promise {
+ return new Promise(async (resolve) => {
+ if (!name) {
+ name = prompt("Branch name:");
+
+ if (!name) {
+ resolve("");
+ return;
}
- }, 1000);
- }
+ }
+ if (name) {
+ selected = null;
+ await $pageRepo.createBranch(name);
+ let inter = setInterval(() => {
+ branches.reload();
+ if ($branches.includes(name!)) {
+ selectedBranch = name!;
+ searchValue = "";
+ clearInterval(inter);
+
+ resolve(name!);
+ }
+ }, 1000);
+ }
+ })
}
function changePage(id: number) {
@@ -101,6 +112,33 @@
selectedBranch = "###!";
selectedBranch = w;
}
+
+ async function newAnnouncement() {
+ const title = prompt("Title: ");
+
+ if (!title) {
+ return;
+ }
+
+ const slug = title.toLowerCase().replace(/ /g, "-");
+
+ const branch = await createBranch(slug)
+
+ selectedPath = "announcements/de/"
+
+ await $pageRepo.createFile(`${selectedPath}${slug}.md`, branch, slug, title);
+ reload();
+
+ const pages = await $pageRepo.listPages(branch);
+
+ const page = pages.find(page => page.path === `${selectedPath}${slug}.md`);
+
+ if (page) {
+ changePage(page.id);
+ } else {
+ alert("Error creating page");
+ }
+ }
- {#if page?.name.endsWith("md")}
+ {#if page?.name.endsWith("md") || page?.name.endsWith("mdx")}
{:else}
dirty = true}/>
diff --git a/src/components/admin/pages/edit/MDEMarkdownEditor.svelte b/src/components/admin/pages/edit/MDEMarkdownEditor.svelte
index 6d4f4d5..b3bb6dc 100644
--- a/src/components/admin/pages/edit/MDEMarkdownEditor.svelte
+++ b/src/components/admin/pages/edit/MDEMarkdownEditor.svelte
@@ -57,4 +57,8 @@
color: black;
}
}
+
+ :global(.CodeMirror) {
+ font-family: monospace !important;
+ }
\ No newline at end of file
diff --git a/src/components/repo/page.ts b/src/components/repo/page.ts
index 7a1203a..f42b1d8 100644
--- a/src/components/repo/page.ts
+++ b/src/components/repo/page.ts
@@ -65,8 +65,8 @@ export class PageRepo {
await fetchWithToken(this.token, "/page/branch", {method: "DELETE", body: JSON.stringify({branch})});
}
- public async createFile(path: string, branch: string = "master"): Promise {
- await fetchWithToken(this.token, `/page?branch=${branch}`, {method: "POST", body: JSON.stringify({path})});
+ public async createFile(path: string, branch: string = "master", slug: string | null = null, title: string | null = null): Promise {
+ await fetchWithToken(this.token, `/page?branch=${branch}`, {method: "POST", body: JSON.stringify({path, slug, title})});
}
public async merge(branch: string, message: string): Promise {
diff --git a/src/components/repo/schem.ts b/src/components/repo/schem.ts
index eaa8fd9..3ec6846 100644
--- a/src/components/repo/schem.ts
+++ b/src/components/repo/schem.ts
@@ -18,7 +18,7 @@
*/
import {fetchWithToken, tokenStore} from "./repo.ts";
-import type {SchematicInfo, SchematicList} from "@type/schem.ts";
+import {type Schematic, type SchematicInfo, type SchematicList, SchematicSchema} from "@type/schem.ts";
import {SchematicInfoSchema, SchematicListSchema} from "@type/schem.ts";
import {derived} from "svelte/store";
@@ -38,6 +38,14 @@ export class SchematicRepo {
return await fetchWithToken(this.token, `/schem/${id}`).then(value => value.json()).then(SchematicInfoSchema.parse);
}
+ public async getSchematicCodeInfo(code: string): Promise {
+ return await fetchWithToken(this.token, `/schem/download/${code}/info`).then(value => value.json()).then(SchematicSchema.parse);
+ }
+
+ public getSchematicDownloadUrl(code: string): string {
+ return `/schem/download/${code}`;
+ }
+
public async uploadSchematic(name: string, content: string) {
return await fetchWithToken(this.token, "/schem", {
method: "POST",
diff --git a/src/content/announcements/de/ein-test.md b/src/content/announcements/de/ein-test.md
deleted file mode 100644
index 326da1e..0000000
--- a/src/content/announcements/de/ein-test.md
+++ /dev/null
@@ -1,7 +0,0 @@
----
-title: [Enter Title]
-description: [Enter Description]
-slug: [Enter Slug]
----
-
-# announcements/de/ein-test.md
\ No newline at end of file
diff --git a/src/content/config.ts b/src/content/config.ts
index a82b375..2964043 100644
--- a/src/content/config.ts
+++ b/src/content/config.ts
@@ -65,6 +65,7 @@ export const rules = defineCollection({
type: "content",
schema: z.object({
translationKey: z.string(),
+ mode: reference("modes").optional(),
}),
});
diff --git a/src/content/rules/de/airship.md b/src/content/rules/de/airship.md
index a7ad772..2e83b80 100644
--- a/src/content/rules/de/airship.md
+++ b/src/content/rules/de/airship.md
@@ -1,5 +1,6 @@
---
translationKey: as
+mode: airship
---
# AirShip-Regelwerk
diff --git a/src/content/rules/de/miniwargear.md b/src/content/rules/de/miniwargear.md
index c9b98de..e98e998 100644
--- a/src/content/rules/de/miniwargear.md
+++ b/src/content/rules/de/miniwargear.md
@@ -1,5 +1,6 @@
---
translationKey: mwg
+mode: miniwargear
---
# MiniWarGear-Regelwerk
diff --git a/src/content/rules/de/wargear.mdx b/src/content/rules/de/wargear.mdx
index d4cf0b5..eebb6b5 100644
--- a/src/content/rules/de/wargear.mdx
+++ b/src/content/rules/de/wargear.mdx
@@ -1,10 +1,9 @@
---
translationKey: wg
+mode: wargear
---
import Link from "../../../components/Link.svelte";
-# WarGear
-
Ein WarGear ist eine Redstone-Kampfmaschine in Minecraft. Diese werden mit einer Vielzahl von Redstonetechniken und TNT-Kanonen ausgestattet und werden gebaut, um anderen WarGears Schaden zuzufügen.
## Basic Wargear
diff --git a/src/content/rules/de/warship.md b/src/content/rules/de/warship.md
index f9ac298..c745365 100644
--- a/src/content/rules/de/warship.md
+++ b/src/content/rules/de/warship.md
@@ -1,5 +1,6 @@
---
translationKey: ws
+mode: warship
---
# WarShip-Regelwerk
diff --git a/src/i18n/common/de.json b/src/i18n/common/de.json
index fe9ed6b..92278f2 100644
--- a/src/i18n/common/de.json
+++ b/src/i18n/common/de.json
@@ -24,7 +24,7 @@
"description": "Jeder Spieler bekommt einen eigenen Bauserver, auf dem ohne Einschränkungen und Lags mit FaWe und Axiom gebaut werden kann."
},
"minigames": {
- "title": "Kleine Pause gefällig?",
+ "title": "Minigames",
"description": {
"1": "Neben der Arena gibt es auch noch Minigames, die du mit anderen Spielern spielen kannst.",
"2": "Klassiker wie MissleWars, TowerRun oder TNTLeague warten auf dich."
@@ -37,11 +37,11 @@
"read": "Mehr Lesen"
},
"prefix": {
- "admin": "Administrator",
- "developer": "Developer",
- "moderator": "Moderator",
- "supporter": "Supporter",
- "builder": "Architekt"
+ "Admin": "Administrator",
+ "Dev": "Developer",
+ "Mod": "Moderator",
+ "Sup": "Supporter",
+ "Arch": "Architekt"
}
},
"status": {
diff --git a/src/i18n/common/en.json b/src/i18n/common/en.json
index b170dc2..e8d17a3 100644
--- a/src/i18n/common/en.json
+++ b/src/i18n/common/en.json
@@ -46,7 +46,7 @@
"description": "Every player gets their own build server to ensure maximum performance and minimal limitations with leading tools like FaWe or Axiom"
},
"minigames": {
- "title": "Need a Break?",
+ "title": "Minigames",
"description": {
"1": "Besides the Arena, you can also play minigames with other players.",
"2": "like MissleWars, Towerrun or TNTLeague"
@@ -58,11 +58,11 @@
"read": "Read More"
},
"prefix": {
- "admin": "Admin",
- "developer": "Developer",
- "moderator": "Moderator",
- "supporter": "Supporter",
- "builder": "Builder"
+ "Admin": "Admin",
+ "Dev": "Developer",
+ "Mod": "Moderator",
+ "Sup": "Supporter",
+ "Arch": "Builder"
}
},
"footer": {
diff --git a/src/pages/index.astro b/src/pages/index.astro
index 6085350..e81131c 100644
--- a/src/pages/index.astro
+++ b/src/pages/index.astro
@@ -35,11 +35,11 @@ const latestPost = posts.sort((a, b) => dayjs(b.data.created).unix() - dayjs(a.d
const prefixColorMap: {
[key: string]: string;
} = {
- PREFIX_ADMIN: "border-red-600 dark:border-red-800 shadow-red-600 dark:shadow-red-800",
- PREFIX_DEVELOPER: "border-sky-600 dark:border-sky-800 shadow-sky-600 dark:shadow-sky-800",
- PREFIX_MODERATOR: "border-amber-600 dark:border-amber-800 shadow-amber-600 dark:shadow-amber-800",
- PREFIX_SUPPORTER: "border-blue-700 dark:border-blue-900 shadow-blue-700 dark:shadow-blue-900",
- PREFIX_BUILDER: "border-green-500 dark:border-green-700 shadow-green-500 dark:shadow-green-700",
+ Admin: "border-red-600 dark:border-red-800 shadow-red-600 dark:shadow-red-800",
+ Dev: "border-sky-600 dark:border-sky-800 shadow-sky-600 dark:shadow-sky-800",
+ Mod: "border-amber-600 dark:border-amber-800 shadow-amber-600 dark:shadow-amber-800",
+ Sup: "border-blue-700 dark:border-blue-900 shadow-blue-700 dark:shadow-blue-900",
+ Arch: "border-green-500 dark:border-green-700 shadow-green-500 dark:shadow-green-700",
};
---
@@ -164,7 +164,7 @@ const prefixColorMap: {
{players.map((v, index) => (
- {index == 0 ?
{t("home.prefix." + prefix.replace("PREFIX_", "").toLowerCase())}
: null}
+ {index == 0 ?
{t("home.prefix." + prefix)}
: null}
{pub.data.name}
- {pub.data.description}
))}
diff --git a/src/pages/regeln/[mode].astro b/src/pages/regeln/[mode].astro
index d40d56b..cc44584 100644
--- a/src/pages/regeln/[mode].astro
+++ b/src/pages/regeln/[mode].astro
@@ -1,8 +1,11 @@
---
-import {getCollection, CollectionEntry} from "astro:content";
+import {getCollection, type CollectionEntry} from "astro:content";
import {astroI18n, createGetStaticPaths, t} from "astro-i18n";
import PageLayout from "@layouts/PageLayout.astro";
import LanguageWarning from "@components/LanguageWarning.astro";
+import EloTable from "@components/EloTable.svelte";
+import {l} from "../../util/util";
+import { Image } from "astro:assets";
export const getStaticPaths = createGetStaticPaths(async () => {
let posts = await getCollection("rules", value => value.id.split("/")[0] === astroI18n.locale);
@@ -17,21 +20,55 @@ export const getStaticPaths = createGetStaticPaths(async () => {
}
});
+ const modes = await getCollection("modes");
+ const publics = await getCollection("publics");
+
return posts.map((page) => ({
- props: {page, german: page.id.split("/")[0] != astroI18n.locale}, params: {mode: page.slug.split("/")[1]},
- }));
+ props: {
+ page,
+ german: page.id.split("/")[0] != astroI18n.locale,
+ mode: modes.find(value => value.id === page.id.split("/")[1].split(".")[0]),
+ publics: publics.filter(value => value.data.gamemode.id === page.id.split("/")[1].split(".")[0]),
+ },
+ params: {
+ mode: page.slug.split("/")[1],
+ },
+ }),
+ );
});
interface Props {
page: CollectionEntry<"rules">,
+ mode: CollectionEntry<"modes">,
+ publics: CollectionEntry<"publics">[],
german: boolean
}
-const {page, german} = Astro.props;
+const {page, german, mode, publics} = Astro.props;
+
const {Content} = await page.render();
---
+ {t(`${page.data.translationKey}.title`)}
+ {mode && mode.data.ranked && (
+
+
+ {t("rules.ranking")}
+
+ )}
+ {publics && (
+
+
+ {t("rules.publics")}
+
+ )}
{german && (
diff --git a/src/pages/regeln/index.astro b/src/pages/regeln/index.astro
index 3f567b3..905431c 100644
--- a/src/pages/regeln/index.astro
+++ b/src/pages/regeln/index.astro
@@ -1,14 +1,9 @@
---
-import wg from "../../images/WarGears.png";
-import mwg from "../../images/MiniWarGears.png";
-import as from "../../images/AirShips.png";
-import ws from "../../images/WarShips.png";
import {t} from "astro-i18n";
-import {getCollection} from "astro:content";
-import PageLayout from "../../layouts/PageLayout.astro";
+import {getCollection, type CollectionEntry} from "astro:content";
+import PageLayout from "@layouts/PageLayout.astro";
import {Image} from "astro:assets";
-import {l} from "../../util/util";
-import {ImageMetadata} from "astro";
+import {l} from "@utils/util";
const imageMap = {
"wg": await getRandomFromMode("wargear"),
@@ -18,10 +13,10 @@ const imageMap = {
"qg": await getRandomFromMode("quickgear"),
};
-async function getRandomFromMode(mode: "wargear" | "airship" | "megawargear" | "microwargear" | "miniwargear" | "quickgear" | "streetfight" | "warship"): Promise {
+async function getRandomFromMode(mode: "wargear" | "airship" | "megawargear" | "microwargear" | "miniwargear" | "quickgear" | "streetfight" | "warship"): Promise> {
const publics = await getCollection("publics", entry => entry.data.gamemode.id === mode);
- return publics[Math.floor(Math.random() * publics.length)].data.image;
+ return publics[Math.floor(Math.random() * publics.length)];
}
const modes = await getCollection("modes", entry => entry.data.main);
@@ -31,16 +26,16 @@ const modes = await getCollection("modes", entry => entry.data.main);
{modes.map(value => (
-
+
+
+
{t(value.data.translationKey + ".title")}
{t("rules." + value.data.translationKey + ".description")}