2023-10-01 10:04:04 +02:00
|
|
|
---
|
2023-12-23 15:36:22 +01:00
|
|
|
import {getCollection} from "astro:content";
|
|
|
|
import {astroI18n, createGetStaticPaths} from "astro-i18n";
|
2023-11-12 22:43:42 +01:00
|
|
|
import PageLayout from "../layouts/PageLayout.astro";
|
2023-12-10 17:14:10 +01:00
|
|
|
import LanguageWarning from "../components/LanguageWarning.astro";
|
2023-10-01 10:04:04 +02:00
|
|
|
|
2023-11-03 20:31:27 +01:00
|
|
|
export const getStaticPaths = createGetStaticPaths(async () => {
|
2023-12-05 17:36:31 +01:00
|
|
|
let posts = await getCollection("pages", value => value.id.split("/")[0] === astroI18n.locale);
|
2023-10-01 10:04:04 +02:00
|
|
|
|
2023-12-05 17:36:31 +01:00
|
|
|
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)
|
|
|
|
}
|
2023-12-23 15:36:22 +01:00
|
|
|
}));
|
|
|
|
});
|
2023-10-01 10:04:04 +02:00
|
|
|
|
|
|
|
const { page } = Astro.props;
|
|
|
|
const { Content } = await page.render();
|
|
|
|
---
|
|
|
|
|
2023-11-12 22:43:42 +01:00
|
|
|
<PageLayout title={page.data.title}>
|
|
|
|
<article>
|
2023-12-05 17:36:31 +01:00
|
|
|
{page.data.german && (
|
2023-12-10 17:14:10 +01:00
|
|
|
<LanguageWarning />
|
2023-12-05 17:36:31 +01:00
|
|
|
)}
|
2023-11-12 22:43:42 +01:00
|
|
|
<h1 class="text-left">{page.data.title}</h1>
|
|
|
|
<Content />
|
|
|
|
</article>
|
|
|
|
</PageLayout>
|
2023-10-01 10:04:04 +02:00
|
|
|
|
|
|
|
<style is:global>
|
|
|
|
article {
|
2023-12-03 19:31:29 +01:00
|
|
|
>* {
|
|
|
|
all: revert;
|
2023-10-12 21:02:57 +02:00
|
|
|
}
|
|
|
|
|
2023-11-03 20:31:27 +01:00
|
|
|
code {
|
|
|
|
@apply dark:text-neutral-400 text-neutral-800;
|
|
|
|
}
|
|
|
|
|
2023-10-01 10:04:04 +02:00
|
|
|
pre.astro-code {
|
2023-10-12 21:02:57 +02:00
|
|
|
@apply w-fit p-4 rounded-md border-2 border-gray-600 my-4;
|
2023-10-01 10:04:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|