Files
website/src/pages/photos/[slug].astro
Max Richter 6aa6ddabb0
All checks were successful
Deploy to SFTP Server / build (push) Successful in 4m0s
feat: add opentags
2025-02-18 16:23:51 +01:00

37 lines
882 B
Plaintext

---
import { getCollection, render } from "astro:content";
import { getLocale } from "astro-i18n-aut";
import { filterCollection, parseSlug } from "@i18n/utils";
import MetaTags from "@components/MetaTags.astro";
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);
return slug === Astro.params.slug;
});
if (!page) {
return new Response("Not found", {
status: 404,
});
}
const { Content } = await render(page);
---
<MetaTags title={page.data.title} cover={page.data.cover?.src} />
<Content />