cleanup insert url

This commit is contained in:
Barrett Ruth 2025-10-08 00:45:53 -04:00
parent efeb921a1b
commit e0a96c87b5
3 changed files with 32 additions and 1 deletions

View file

@ -111,3 +111,16 @@ pre {
font-size: 0.9em;
}
}
.clone-banner {
display: flex;
justify-content: center;
align-items: center;
font-family: 'Apercu Mono', monospace;
}
.clone-banner code {
font-size: 0.95em;
user-select: all;
white-space: nowrap;
}

View file

@ -3,4 +3,4 @@ title: "wp.git"
date: "07/10/2025"
---
some of my wallpapers: `git clone https://git.barrettruth.com/wp.git`
some of my wallpapers

View file

@ -14,8 +14,26 @@ const entry = await getEntry("git", slug);
if (!entry) return Astro.redirect("/404");
const { Content } = await entry.render();
const repoName = `${slug}.git`;
let cloneCommand = "";
try {
const res = await fetch("https://git.barrettruth.com/api/repositories");
const json = res.ok ? await res.json() : { repositories: [] };
const exists = json.repositories?.includes(repoName);
if (exists) {
cloneCommand = `git clone https://git.barrettruth.com/${repoName}`;
}
} catch {}
---
<PostLayout frontmatter={entry.data} post={entry}>
{cloneCommand && (
<div class="clone-banner">
<pre><code class="language-bash">{cloneCommand}</code></pre>
</div>
)}
<Content />
</PostLayout>