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

39 lines
1.1 KiB
Plaintext

---
import { astroI18n, createStaticPaths } from "astro-i18n";
// astroI18n.init(Astro);
import { getCollection } from "astro:content";
import EditorialContent from "../../components/EditorialContent.astro";
import BaseLayout from "../../layouts/BaseLayout.astro";
export const getStaticPaths = createStaticPaths(async ({ langCode }) => {
const articles = await getCollection("articles", ({ data }) => {
return data.lang === langCode;
});
return articles.map((article) => ({
params: { slug: article.slug },
props: { article },
}));
}, import.meta.url);
// export async function getStaticPaths() {
// const articles = await getCollection("articles", ({ data }) => {
// return data.lang === astroI18n.langCode;
// });
// return articles.map((article) => ({
// params: { slug: article.slug },
// props: { article },
// }));
// }
const { article } = Astro.props;
// article is ok in logs but not diaplyed properly on the actual page
console.log(article);
---
<BaseLayout pageTitle={article.data.title}>
{article.data.lang}
<EditorialContent content={article} />
</BaseLayout>