website/src/pages/photos/[slug].astro
Max Richter 4c3e35efbf
Some checks failed
Deploy to SFTP Server / build (push) Failing after 5m43s
feat: add madeira blog post upgrade astro
2025-02-16 15:33:45 +01:00

36 lines
838 B
Plaintext

---
import { getCollection, render } 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("photos");
const paths = pages.map((page) => {
const [slug] = parseSlug(page.id);
return { params: { slug }, props: { ...page } };
});
return paths;
}
const pages = await getCollection("photos");
const page = filterCollection(pages, locale).find((page) => {
const [slug] = parseSlug(page.id);
console.log({ slug, id: page.id, params: Astro.params.slug, locale });
return slug === Astro.params.slug;
});
if (!page) {
return new Response("Not found", {
status: 404,
});
}
const { Content } = await render(page);
---
<Content />