cleanup
This commit is contained in:
parent
17d52f5b07
commit
5af8e1373e
9 changed files with 175 additions and 162 deletions
52
src/pages/git.astro
Normal file
52
src/pages/git.astro
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
---
|
||||
import BaseLayout from "../layouts/BaseLayout.astro";
|
||||
|
||||
const title = "Git Repositories";
|
||||
---
|
||||
|
||||
<BaseLayout title={title}>
|
||||
<slot name="head" slot="head">
|
||||
<link rel="stylesheet" href="/styles/index.css" />
|
||||
</slot>
|
||||
|
||||
<div class="content">
|
||||
<ul class="topics" id="repo-list">
|
||||
<li class="topic"></li>
|
||||
</ul>
|
||||
<div class="posts" id="posts"></div>
|
||||
</div>
|
||||
|
||||
<script slot="scripts" type="module">
|
||||
const listEl = document.getElementById("repo-list");
|
||||
|
||||
async function loadRepos() {
|
||||
try {
|
||||
const res = await fetch("https://git.barrettruth.com/api/repositories", { mode: "cors" });
|
||||
if (!res.ok) throw new Error("HTTP " + res.status);
|
||||
const data = await res.json();
|
||||
const repos = Array.isArray(data?.repositories) ? data.repositories : [];
|
||||
|
||||
listEl.innerHTML = "";
|
||||
|
||||
repos.sort((a, b) => a.localeCompare(b));
|
||||
|
||||
for (const name of repos) {
|
||||
const cls = `repo-${name}`;
|
||||
|
||||
const li = document.createElement("li");
|
||||
li.className = `topic ${cls}`;
|
||||
|
||||
const a = document.createElement("a");
|
||||
// a.href = `https://git.barrettruth.com/${name}`;
|
||||
a.textContent = name;
|
||||
a.setAttribute("data-topic", name);
|
||||
|
||||
li.appendChild(a);
|
||||
listEl.appendChild(li);
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
loadRepos();
|
||||
</script>
|
||||
</BaseLayout>
|
||||
Loading…
Add table
Add a link
Reference in a new issue