barrettruth.com/src/pages/git/[slug].astro
2025-10-08 00:02:00 -04:00

21 lines
665 B
Text

---
import { getEntry } from "astro:content";
import PostLayout from "../../layouts/PostLayout.astro";
export async function getStaticPaths() {
const res = await fetch("https://git.barrettruth.com/api/repositories");
const json = res.ok ? await res.json() : { repositories: [] };
const repos = (json.repositories || []).map((r) => r.replace(/\.git$/, ""));
return repos.map((slug) => ({ params: { slug } }));
}
const { slug } = Astro.params;
const entry = await getEntry("git", slug);
if (!entry) return Astro.redirect("/404");
const { Content } = await entry.render();
---
<PostLayout frontmatter={entry.data} post={entry}>
<Content />
</PostLayout>