Refactor
This commit is contained in:
@ -1,13 +1,26 @@
|
||||
---
|
||||
import {getCollection} from 'astro:content'
|
||||
import {astroI18n, createGetStaticPaths} from "astro-i18n";
|
||||
import {astroI18n, createGetStaticPaths, t} from "astro-i18n";
|
||||
import PageLayout from "../layouts/PageLayout.astro";
|
||||
|
||||
export const getStaticPaths = createGetStaticPaths(async () => {
|
||||
let posts = await getCollection("pages");
|
||||
let posts = await getCollection("pages", value => value.id.split("/")[0] === astroI18n.locale);
|
||||
|
||||
return posts.filter(value => value.id.split("/")[0] === astroI18n.locale).map((page) => ({
|
||||
props: { page }, params: { slug: page.slug }
|
||||
function fixLink(slug: string): string {
|
||||
if (astroI18n.locales.includes(slug.split("/")[0])) {
|
||||
return slug.split("/").slice(1).join("/");
|
||||
} else {
|
||||
return slug;
|
||||
}
|
||||
}
|
||||
|
||||
return posts.map((page) => ({
|
||||
props: {
|
||||
page
|
||||
},
|
||||
params: {
|
||||
slug: fixLink(page.slug)
|
||||
}
|
||||
}) )
|
||||
})
|
||||
|
||||
@ -18,6 +31,12 @@ const { Content } = await page.render();
|
||||
|
||||
<PageLayout title={page.data.title}>
|
||||
<article>
|
||||
{page.data.german && (
|
||||
<div class="bg-yellow-100 border-l-4 border-yellow-500 text-yellow-700 p-4" role="alert">
|
||||
<div class="font-bold">{t("warning.title", {}, {route: "/rules"})}</div>
|
||||
<div>{t("warning.text", {}, {route: "/rules"})}</div>
|
||||
</div>
|
||||
)}
|
||||
<h1 class="text-left">{page.data.title}</h1>
|
||||
<Content />
|
||||
</article>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---
|
||||
import {astroI18n, createGetStaticPaths} from "astro-i18n";
|
||||
import {astroI18n, createGetStaticPaths, t} from "astro-i18n";
|
||||
import {getCollection, CollectionEntry} from "astro:content";
|
||||
import PageLayout from "../../layouts/PageLayout.astro";
|
||||
import {TagSolid, CalendarMonthSolid} from "flowbite-svelte-icons"
|
||||
@ -37,6 +37,12 @@ const { Content } = await post.render();
|
||||
month: 'short',
|
||||
year: 'numeric'
|
||||
}).format(post.data.created)} </h5>
|
||||
{post.data.german && (
|
||||
<div class="bg-yellow-100 border-l-4 border-yellow-500 text-yellow-700 p-4" role="alert">
|
||||
<div class="font-bold">{t("warning.title", {}, {route: "/rules"})}</div>
|
||||
<div>{t("warning.text", {}, {route: "/rules"})}</div>
|
||||
</div>
|
||||
)}
|
||||
<Content />
|
||||
<script>
|
||||
import type {ExtendedEvent} from "../../components/types/event";
|
||||
@ -44,6 +50,7 @@ const { Content } = await post.render();
|
||||
// @ts-ignore
|
||||
import {get} from "svelte/store";
|
||||
import {eventRepo} from "../../components/repo/repo";
|
||||
import GroupTable from "../../components/GroupTable.svelte";
|
||||
const eventMounts: Map<string, ((ev: ExtendedEvent) => void)[]> = new Map();
|
||||
|
||||
class FightTableElement extends HTMLElement {
|
||||
@ -65,7 +72,27 @@ const { Content } = await post.render();
|
||||
}
|
||||
}
|
||||
|
||||
class GroupTableElement extends HTMLElement {
|
||||
connectedCallback(): void {
|
||||
if (!eventMounts.has(this.dataset['event'])) {
|
||||
eventMounts.set(this.dataset['event'], [])
|
||||
}
|
||||
const rows = Number.parseInt(this.dataset['rows']);
|
||||
eventMounts.get(this.dataset['event']).push(ev => {
|
||||
new GroupTable({
|
||||
target: this,
|
||||
props: {
|
||||
event: ev,
|
||||
group: this.dataset['group'],
|
||||
rows: !isNaN(rows) ? rows : 1,
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define('fight-table', FightTableElement);
|
||||
customElements.define('group-table', GroupTableElement);
|
||||
|
||||
function mountEvent() {
|
||||
for (const key of eventMounts.keys()) {
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
import PageLayout from "../layouts/PageLayout.astro";
|
||||
import {getCollection} from "astro:content";
|
||||
import {t} from "astro-i18n";
|
||||
import {l} from "../util/util";
|
||||
|
||||
const downloads = await getCollection("downloads");
|
||||
---
|
||||
@ -15,7 +16,7 @@ const downloads = await getCollection("downloads");
|
||||
<div class="flex flex-col">
|
||||
{typeof e.data.url === 'object' ?
|
||||
Object.entries(e.data.url).map(value => (
|
||||
<a href={value[1]} class="text-blue-500 hover:underline w-fit">{t(value[0])}</a>
|
||||
<a href={value[1].startsWith("/") ? l(value[1]) : value[1]} class="text-blue-500 hover:underline w-fit">{t(value[0])}</a>
|
||||
))
|
||||
:
|
||||
<a href={e.data.url} class="text-blue-500 hover:underline w-fit">{t("Download")}</a>
|
||||
|
||||
@ -4,19 +4,21 @@ import {astroI18n} from "astro-i18n";
|
||||
|
||||
import NavbarLayout from "../../layouts/NavbarLayout.astro";
|
||||
import {l} from "../../util/util";
|
||||
import PageLayout from "../../layouts/PageLayout.astro";
|
||||
let posts = await getCollection("help", entry => entry.id.split("/")[0] === astroI18n.locale);
|
||||
---
|
||||
|
||||
<NavbarLayout title="Helpcenter">
|
||||
<PageLayout title="Helpcenter">
|
||||
<div>
|
||||
<h1>Helpcenter</h1>
|
||||
<h1 class="text-red-700 text-4xl">WIP!</h1>
|
||||
{posts.map(value => (
|
||||
<a href={l("/help/" + value.slug)}>
|
||||
<h2>{value.data.title}</h2>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
</NavbarLayout>
|
||||
</PageLayout>
|
||||
|
||||
<style>
|
||||
div {
|
||||
|
||||
@ -14,7 +14,8 @@ const imageMap = {
|
||||
"wg": wg,
|
||||
"mwg": mwg,
|
||||
"as": as,
|
||||
"ws": ws
|
||||
"ws": ws,
|
||||
"qg": mwg
|
||||
}
|
||||
|
||||
const modes = await getCollection("modes", entry => entry.data.main)
|
||||
@ -30,7 +31,7 @@ const modes = await getCollection("modes", entry => entry.data.main)
|
||||
<div>{t(value.data.translationKey + ".description")}</div>
|
||||
<div class="mt-2 flex flex-col">
|
||||
<a href={l(`/rules/${value.id}`)} class="text-yellow-300 hover:underline w-fit">{t("rules")}</a>
|
||||
<a href="/public" class="text-yellow-300 hover:underline w-fit">{t("council")}</a>
|
||||
<a href={l(`/announcements/tags/${value.id}`)} class="text-yellow-300 hover:underline w-fit">{t("announcements")}</a>
|
||||
{value.data.ranked ? <a href={l(`/ranked/${value.id}`)} class="text-yellow-300 hover:underline w-fit">{t(`ranking`)}</a> : null}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user