organize
This commit is contained in:
parent
024226ef53
commit
81fca03582
5 changed files with 38 additions and 4 deletions
21
src/pages/git/[slug].astro
Normal file
21
src/pages/git/[slug].astro
Normal 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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue