Files
validation-lab-site/src/layouts/Site.astro
T

84 lines
2.5 KiB
Plaintext

---
const pageFiles = import.meta.glob("../pages/**/*.md", { eager: true });
const pages = Object.entries(pageFiles)
.map(([file, mod]) => {
const slug = file.replace("../pages", "").replace(/\.md$/, "");
return {
href: slug === "/index" ? "/" : slug,
label: mod.frontmatter?.title ?? slug,
};
})
.sort((a, b) => a.href.localeCompare(b.href));
// Markdown pages hand their frontmatter to the layout as `frontmatter`.
const { title } = Astro.props.frontmatter ?? Astro.props;
---
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{title}</title>
<style is:global>
:root {
--ink: #1f2937;
--muted: #6b7280;
--accent: #4f46e5;
--line: #e5e7eb;
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
color: var(--ink);
line-height: 1.65;
}
nav {
display: flex;
gap: 1.25rem;
align-items: center;
padding: 0.9rem 2rem;
border-bottom: 1px solid var(--line);
}
nav .brand { font-weight: 700; margin-right: auto; }
nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
nav a:hover, nav a[aria-current="page"] { color: var(--accent); }
main { max-width: 44rem; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }
main :is(h1, h2, h3) { line-height: 1.25; }
main h1 { font-size: 2.1rem; margin: 0 0 1.25rem; }
main h2 { font-size: 1.45rem; margin-top: 2.25rem; }
main img { max-width: 100%; height: auto; border-radius: 0.5rem; }
main blockquote {
margin: 1.5rem 0;
padding: 0.5rem 1.25rem;
border-left: 3px solid var(--accent);
color: var(--muted);
}
main ul, main ol { padding-inline-start: 1.5rem; }
footer {
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 0.85rem;
padding: 1.25rem 2rem;
text-align: center;
}
</style>
</head>
<body>
<nav>
<span class="brand">{title}</span>
{pages.map((p) => (
<a href={p.href} aria-current={Astro.url.pathname === p.href ? "page" : undefined}>
{p.label}
</a>
))}
</nav>
<main>
<slot />
</main>
<footer>
This page is editable in the browser at
<a href="/admin/">/admin/</a> — no git knowledge required.
</footer>
</body>
</html>