This commit is contained in:
Barrett Ruth 2025-10-08 00:02:00 -04:00
parent 024226ef53
commit 81fca03582
5 changed files with 38 additions and 4 deletions

View file

@ -5,8 +5,6 @@ import PostLayout from "../../layouts/PostLayout.astro";
export async function getStaticPaths() {
const gists = await getCollection("gists");
console.log(gists)
return gists.map((gist) => ({
params: { slug: gist.slug },
props: { gist },

View file

@ -0,0 +1,21 @@
---
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>