- buildNavTree: every non-draft page nested by vault folder; folders link to their (real or synthetic) index page and take its title when set - NavTree component: recursive details/summary tree, no JS — folders on the current path render open, current page gets aria-current styling - layout: sticky left sidebar >=72rem, flows after the footer as a site index on narrow screens Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
261 lines
6.7 KiB
Plaintext
261 lines
6.7 KiB
Plaintext
---
|
|
import 'katex/dist/katex.min.css';
|
|
import { getCollection } from 'astro:content';
|
|
import { buildNavTree } from '../lib/nav.mjs';
|
|
import NavTree from '../components/NavTree.astro';
|
|
|
|
interface Props {
|
|
title: string;
|
|
description?: string;
|
|
}
|
|
const { title, description } = Astro.props;
|
|
const isHome = Astro.url.pathname === '/';
|
|
const navTree = buildNavTree(await getCollection('garden'));
|
|
---
|
|
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>{title}{isHome ? '' : ' // Wesley Ray'}</title>
|
|
{description && <meta name="description" content={description} />}
|
|
<script
|
|
defer
|
|
data-domain="garden.c0smere.net"
|
|
src="https://plausible.io/js/script.js"></script>
|
|
</head>
|
|
<body>
|
|
<div class="layout">
|
|
<div class="content-col">
|
|
<header>
|
|
{!isHome && <nav><a href="/">← home</a></nav>}
|
|
</header>
|
|
<main>
|
|
<slot />
|
|
</main>
|
|
<footer>
|
|
<p>
|
|
Wesley Ray · <a href="https://blog.c0smere.net">blog</a> ·
|
|
<a href="https://git.c0smere.net/wes">git</a> ·
|
|
<a href="https://resume.c0smere.net">resume</a>
|
|
</p>
|
|
</footer>
|
|
</div>
|
|
<aside class="sidebar">
|
|
<p class="sidebar-title"><a href="/">the garden</a></p>
|
|
<NavTree nodes={navTree} currentPath={Astro.url.pathname} />
|
|
</aside>
|
|
</div>
|
|
|
|
<script>
|
|
// mermaid: only load the (large) module on pages that need it
|
|
const blocks = document.querySelectorAll('pre > code.language-mermaid');
|
|
if (blocks.length) {
|
|
const { default: mermaid } = await import('mermaid');
|
|
blocks.forEach((code) => {
|
|
const pre = document.createElement('pre');
|
|
pre.className = 'mermaid';
|
|
pre.textContent = code.textContent ?? '';
|
|
code.parentElement?.replaceWith(pre);
|
|
});
|
|
mermaid.initialize({
|
|
startOnLoad: false,
|
|
theme: matchMedia('(prefers-color-scheme: dark)').matches
|
|
? 'dark'
|
|
: 'default',
|
|
});
|
|
await mermaid.run();
|
|
}
|
|
</script>
|
|
|
|
<style is:global>
|
|
:root {
|
|
--bg: #faf8f8;
|
|
--fg: #2b2b2b;
|
|
--muted: #4e4e4e;
|
|
--faint: #e5e5e5;
|
|
--accent: #284b63;
|
|
--accent2: #84a59d;
|
|
color-scheme: light dark;
|
|
}
|
|
@media (prefers-color-scheme: dark) {
|
|
:root {
|
|
--bg: #161618;
|
|
--fg: #ebebec;
|
|
--muted: #d4d4d4;
|
|
--faint: #393639;
|
|
--accent: #7b97aa;
|
|
--accent2: #84a59d;
|
|
}
|
|
}
|
|
* {
|
|
box-sizing: border-box;
|
|
}
|
|
body {
|
|
margin: 0;
|
|
background: var(--bg);
|
|
color: var(--fg);
|
|
font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
|
|
line-height: 1.6;
|
|
}
|
|
.layout {
|
|
margin: 0 auto;
|
|
padding: 1.5rem 1rem 3rem;
|
|
max-width: 44rem;
|
|
}
|
|
/* mobile: sidebar flows after the footer as a full site index */
|
|
.sidebar {
|
|
margin-top: 2.5rem;
|
|
padding-top: 1rem;
|
|
border-top: 1px solid var(--faint);
|
|
}
|
|
@media (min-width: 72rem) {
|
|
.layout {
|
|
display: grid;
|
|
grid-template-columns: 17rem minmax(0, 44rem);
|
|
gap: 3rem;
|
|
max-width: 66rem;
|
|
}
|
|
.sidebar {
|
|
order: -1;
|
|
margin-top: 0;
|
|
padding-top: 0;
|
|
border-top: none;
|
|
position: sticky;
|
|
top: 0;
|
|
align-self: start;
|
|
max-height: 100vh;
|
|
overflow-y: auto;
|
|
padding: 1.5rem 0.5rem 1.5rem 0;
|
|
}
|
|
}
|
|
.sidebar-title {
|
|
margin: 0 0 0.5rem;
|
|
font-weight: 600;
|
|
}
|
|
.sidebar-title a {
|
|
color: var(--fg);
|
|
text-decoration: none;
|
|
}
|
|
.sidebar ul {
|
|
list-style: none;
|
|
margin: 0;
|
|
padding-left: 0.85rem;
|
|
font-size: 0.85rem;
|
|
}
|
|
.sidebar > ul,
|
|
.sidebar-title + ul {
|
|
padding-left: 0;
|
|
}
|
|
.sidebar li {
|
|
margin: 0.15rem 0;
|
|
}
|
|
.sidebar a {
|
|
color: var(--muted);
|
|
text-decoration: none;
|
|
}
|
|
.sidebar a:hover {
|
|
color: var(--accent);
|
|
text-decoration: underline;
|
|
}
|
|
.sidebar a[aria-current='page'] {
|
|
color: var(--accent);
|
|
font-weight: 600;
|
|
}
|
|
.sidebar summary {
|
|
cursor: pointer;
|
|
list-style: none;
|
|
}
|
|
.sidebar summary::before {
|
|
content: '▸';
|
|
display: inline-block;
|
|
width: 0.9em;
|
|
color: var(--muted);
|
|
font-size: 0.8em;
|
|
transition: transform 0.15s;
|
|
}
|
|
.sidebar details[open] > summary::before {
|
|
transform: rotate(90deg);
|
|
}
|
|
.sidebar summary a {
|
|
font-weight: 550;
|
|
color: var(--fg);
|
|
}
|
|
a {
|
|
color: var(--accent);
|
|
}
|
|
h1, h2, h3, h4 {
|
|
line-height: 1.25;
|
|
}
|
|
header nav {
|
|
margin-bottom: 1rem;
|
|
font-size: 0.9rem;
|
|
}
|
|
footer {
|
|
margin-top: 3rem;
|
|
padding-top: 1rem;
|
|
border-top: 1px solid var(--faint);
|
|
font-size: 0.85rem;
|
|
color: var(--muted);
|
|
}
|
|
img {
|
|
max-width: 100%;
|
|
height: auto;
|
|
}
|
|
pre {
|
|
padding: 0.9rem 1rem;
|
|
border-radius: 6px;
|
|
overflow-x: auto;
|
|
font-size: 0.88rem;
|
|
}
|
|
:not(pre) > code {
|
|
background: var(--faint);
|
|
padding: 0.1em 0.35em;
|
|
border-radius: 4px;
|
|
font-size: 0.9em;
|
|
}
|
|
table {
|
|
border-collapse: collapse;
|
|
display: block;
|
|
overflow-x: auto;
|
|
max-width: 100%;
|
|
}
|
|
th, td {
|
|
border: 1px solid var(--faint);
|
|
padding: 0.35rem 0.6rem;
|
|
}
|
|
blockquote {
|
|
margin: 1rem 0;
|
|
padding: 0.1rem 1rem;
|
|
border-left: 3px solid var(--accent2);
|
|
color: var(--muted);
|
|
}
|
|
.callout {
|
|
border-left-width: 4px;
|
|
border-radius: 4px;
|
|
background: color-mix(in srgb, var(--accent2) 8%, transparent);
|
|
}
|
|
.callout-title {
|
|
color: var(--accent);
|
|
}
|
|
.callout-warning, .callout-attention, .callout-important {
|
|
border-left-color: #c9803a;
|
|
}
|
|
.callout-warning .callout-title,
|
|
.callout-attention .callout-title,
|
|
.callout-important .callout-title {
|
|
color: #c9803a;
|
|
}
|
|
/* dark-mode-aware shiki dual themes */
|
|
@media (prefers-color-scheme: dark) {
|
|
.astro-code,
|
|
.astro-code span {
|
|
color: var(--shiki-dark) !important;
|
|
background-color: var(--shiki-dark-bg) !important;
|
|
}
|
|
}
|
|
</style>
|
|
</body>
|
|
</html>
|