Migrate Site to German as Default Locale
This commit is contained in:
65
src/pages/regeln/[mode].astro
Normal file
65
src/pages/regeln/[mode].astro
Normal file
@@ -0,0 +1,65 @@
|
||||
---
|
||||
import {getCollection, CollectionEntry} from "astro:content";
|
||||
import {astroI18n, createGetStaticPaths, t} from "astro-i18n";
|
||||
import PageLayout from "@layouts/PageLayout.astro";
|
||||
import LanguageWarning from "@components/LanguageWarning.astro";
|
||||
|
||||
export const getStaticPaths = createGetStaticPaths(async () => {
|
||||
let posts = await getCollection("rules", value => value.id.split("/")[0] === astroI18n.locale);
|
||||
|
||||
const germanPosts = await getCollection("rules", entry => entry.id.split("/")[0] === astroI18n.fallbackLocale);
|
||||
|
||||
germanPosts.forEach(value => {
|
||||
if (posts.find(post => post.id.split("/")[1] === value.id.split("/")[1])) {
|
||||
return;
|
||||
} else {
|
||||
posts.push(value);
|
||||
}
|
||||
});
|
||||
|
||||
return posts.map((page) => ({
|
||||
props: {page, german: page.id.split("/")[0] != astroI18n.locale}, params: {mode: page.slug.split("/")[1]},
|
||||
}));
|
||||
});
|
||||
|
||||
interface Props {
|
||||
page: CollectionEntry<"rules">,
|
||||
german: boolean
|
||||
}
|
||||
|
||||
const {page, german} = Astro.props;
|
||||
const {Content} = await page.render();
|
||||
---
|
||||
|
||||
<PageLayout title={t("rules.title", {mode: t(`${page.data.translationKey}.title`)})}>
|
||||
<article>
|
||||
{german && (
|
||||
<LanguageWarning/>
|
||||
)}
|
||||
<Content/>
|
||||
</article>
|
||||
</PageLayout>
|
||||
|
||||
<style is:global>
|
||||
article {
|
||||
> * {
|
||||
all: revert;
|
||||
}
|
||||
|
||||
code {
|
||||
@apply dark:text-neutral-400 text-neutral-800;
|
||||
}
|
||||
|
||||
pre.astro-code {
|
||||
@apply w-fit p-4 rounded-md border-2 border-gray-600 my-4;
|
||||
}
|
||||
|
||||
a {
|
||||
@apply text-neutral-800 dark:text-neutral-400 hover:underline;
|
||||
}
|
||||
}
|
||||
|
||||
link-to {
|
||||
display: contents;
|
||||
}
|
||||
</style>
|
||||
43
src/pages/regeln/index.astro
Normal file
43
src/pages/regeln/index.astro
Normal file
@@ -0,0 +1,43 @@
|
||||
---
|
||||
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 {Image} from "astro:assets";
|
||||
import {l} from "../../util/util";
|
||||
|
||||
const imageMap = {
|
||||
"wg": wg,
|
||||
"mwg": mwg,
|
||||
"as": as,
|
||||
"ws": ws,
|
||||
"qg": mwg,
|
||||
};
|
||||
|
||||
const modes = await getCollection("modes", entry => entry.data.main);
|
||||
---
|
||||
|
||||
<PageLayout title={t("rules.page")}>
|
||||
{modes.map(value => (
|
||||
<div class="dark:bg-neutral-800 rounded-md p-4 border border-neutral-400 shadow-md my-4 flex flex-col
|
||||
md:flex-row">
|
||||
<Image height="300" width="300" src={imageMap[value.data.translationKey]}
|
||||
alt={t("rules." + value.data.translationKey + ".title")} class="dark:invert"></Image>
|
||||
<div class="ml-4">
|
||||
<h1 class="text-2xl font-bold">{t(value.data.translationKey + ".title")}</h1>
|
||||
<div>{t("rules." + 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.rules")}</a>
|
||||
<a href={l(`/announcements/tags/${value.id}`)}
|
||||
class="text-yellow-300 hover:underline w-fit">{t("rules.announcements")}</a>
|
||||
{value.data.ranked
|
||||
? <a href={l(`/ranked/${value.id}`)}
|
||||
class="text-yellow-300 hover:underline w-fit">{t("rules.ranking")}</a>
|
||||
: null}
|
||||
</div>
|
||||
</div>
|
||||
</div>))}
|
||||
</PageLayout>
|
||||
Reference in New Issue
Block a user