website-astro/src/pages/articles/[...slug].astro

28 lines
755 B
Plaintext
Raw Normal View History

2022-12-22 11:01:52 +01:00
---
import { astroI18n, extractRouteLangCode } from "astro-i18n";
2022-12-26 23:15:27 +01:00
astroI18n.init(Astro);
2022-12-22 11:01:52 +01:00
2022-12-26 23:15:27 +01:00
import { getCollection } from "astro:content";
import EditorialContent from "../../components/EditorialContent.astro";
2022-12-22 11:01:52 +01:00
2022-12-26 23:15:27 +01:00
import BaseLayout from "../../layouts/BaseLayout.astro";
2022-12-22 11:01:52 +01:00
2022-12-26 23:15:27 +01:00
export async function getStaticPaths() {
const articles = await getCollection("articles", ({ data }) => {
console.log(extractRouteLangCode(import.meta.url));
return data.lang === extractRouteLangCode(import.meta.url);
2022-12-22 11:01:52 +01:00
});
2022-12-26 23:15:27 +01:00
return articles.map((article) => ({
2023-02-03 11:21:01 +01:00
params: { slug: article.slug },
2022-12-26 23:15:27 +01:00
props: { article },
}));
2022-12-22 11:01:52 +01:00
}
2022-12-26 23:15:27 +01:00
const { article } = Astro.props;
2022-12-22 11:01:52 +01:00
---
2022-12-26 23:15:27 +01:00
<BaseLayout pageTitle={article.data.title}>
{article.data.lang}
2022-12-26 23:15:27 +01:00
<EditorialContent content={article} />
2022-12-22 11:01:52 +01:00
</BaseLayout>