barrettruth.com/src/components/Header.astro
2025-11-09 17:25:39 -05:00

48 lines
1.1 KiB
Text

---
const path = Astro.url.pathname;
const is404 = path === "/404.html" || path === "/404";
function deriveTopic() {
if (is404) return "/not-found";
if (path.startsWith("/about")) return "/about";
if (path === "/gist" || path.startsWith("/gist/")) return "/gist";
if (path === "/git" || path.startsWith("/git/")) return "/git";
return "";
}
const topic = deriveTopic();
const promptText = topic ? `barrett@ruth:~$ ${topic}` : "barrett@ruth:~$";
---
<header>
<a href="/" class="home-link" style="text-decoration: none; color: inherit">
<div class="terminal-container">
<span class="terminal-prompt">{promptText}</span>
<span class="terminal-cursor"></span>
</div>
</a>
<span id="theme-toggle">☼⊂ʕ•ᴥ•ʔ</span>
</header>
<style>
#theme-toggle {
cursor: pointer;
user-select: none;
}
@media (max-width: 768px) {
header {
flex-direction: row;
flex-wrap: wrap;
gap: 10px;
}
.terminal-container {
flex: 1 1 auto;
min-width: 0;
}
#theme-toggle {
flex: 0 0 auto;
}
}
</style>
<script src="/scripts/index.js" is:inline></script>