website/src/pages/projects/[slug].astro
Max Richter 82eb0657e2
All checks were successful
Deploy to SFTP Server / build (push) Successful in 6m11s
refactor: use markdown layouts
2024-04-06 19:11:06 +02:00

35 lines
762 B
Plaintext

---
import { getCollection } from "astro:content";
import { getLocale } from "astro-i18n-aut";
import { filterCollection, parseSlug } from "@i18n/utils";
const locale = getLocale(Astro.url);
export async function getStaticPaths() {
const pages = await getCollection("projects");
const paths = pages.map((page) => {
const [slug] = parseSlug(page.id);
return { params: { slug }, props: { ...page } };
});
return paths;
}
const pages = await getCollection("projects");
const page = filterCollection(pages, locale).find((page) => {
const [slug] = parseSlug(page.id);
return slug === Astro.params.slug;
});
if (!page) {
return new Response("Not found", {
status: 404,
});
}
const { Content } = await page.render();
---
<Content />