57 Zeilen
1.3 KiB
Plaintext
57 Zeilen
1.3 KiB
Plaintext
---
|
|
import {getCollection} from "astro:content";
|
|
import {astroI18n, createGetStaticPaths} from "astro-i18n";
|
|
import PageLayout from "../layouts/PageLayout.astro";
|
|
import LanguageWarning from "../components/LanguageWarning.astro";
|
|
|
|
export const getStaticPaths = createGetStaticPaths(async () => {
|
|
let posts = await getCollection("pages", value => value.id.split("/")[0] === astroI18n.locale);
|
|
|
|
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)
|
|
}
|
|
}));
|
|
});
|
|
|
|
const { page } = Astro.props;
|
|
const { Content } = await page.render();
|
|
---
|
|
|
|
<PageLayout title={page.data.title}>
|
|
<article>
|
|
{page.data.german && (
|
|
<LanguageWarning />
|
|
)}
|
|
<h1 class="text-left">{page.data.title}</h1>
|
|
<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;
|
|
}
|
|
}
|
|
</style>
|