feat: render current spec on index page instead of redirecting

- Update index.astro to fetch and render the current spec version
  directly rather than redirecting to /spec/{version}
- Move .spec-content styles from [version].astro to global.css
  to share styles between index and version pages
- Rebuild site with new index page
This commit is contained in:
Claude
2026-01-12 20:12:27 +00:00
committed by Jim Myhrberg
parent 58f310bb8c
commit 868e67ad4b
12 changed files with 490 additions and 106 deletions

View File

@@ -1,6 +1,21 @@
---
import { getCollection, render } from "astro:content";
import Default from "../layouts/Default.astro";
import { config } from "../config";
// Redirect to current version
return Astro.redirect(`/spec/${config.currentVersion}`);
// Get all specs and find the current version
const specs = await getCollection("spec");
const currentSpec = specs.find((s) => s.data.version === config.currentVersion);
if (!currentSpec) {
return Astro.redirect("/404");
}
const { Content } = await render(currentSpec);
---
<Default title={currentSpec.data.title} version={currentSpec.data.version}>
<article class="spec-content">
<Content />
</article>
</Default>

View File

@@ -19,84 +19,3 @@ const { Content } = await render(spec);
<Content />
</article>
</Default>
<style is:global>
.spec-content {
/* Prose-like styling for spec content */
}
.spec-content h1 {
margin-bottom: 0.5em;
}
.spec-content h2 {
margin-top: 2em;
margin-bottom: 0.75em;
padding-bottom: 0.3em;
border-bottom: 1px solid #eee;
}
.dark .spec-content h2 {
border-bottom-color: #333;
}
.spec-content h3 {
margin-top: 1.5em;
margin-bottom: 0.5em;
}
.spec-content p {
margin-bottom: 1em;
}
.spec-content ul,
.spec-content ol {
margin-bottom: 1em;
padding-left: 2em;
}
.spec-content li {
margin-bottom: 0.25em;
}
.spec-content a {
color: #1f8dd6;
text-decoration: none;
}
.spec-content a:hover {
text-decoration: underline;
}
.dark .spec-content a {
color: #4da6e8;
}
.spec-content img {
max-width: 100%;
height: auto;
margin: 1em 0;
}
.spec-content blockquote {
margin: 1em 0;
padding-left: 1em;
border-left: 4px solid #ddd;
color: #666;
}
.dark .spec-content blockquote {
border-left-color: #444;
color: #aaa;
}
.spec-content hr {
margin: 2em 0;
border: none;
border-top: 1px solid #eee;
}
.dark .spec-content hr {
border-top-color: #333;
}
</style>

View File

@@ -132,4 +132,80 @@
.menu-link {
transition: all 0.2s ease-out;
}
/* Spec content styling */
.spec-content h1 {
margin-bottom: 0.5em;
}
.spec-content h2 {
margin-top: 2em;
margin-bottom: 0.75em;
padding-bottom: 0.3em;
border-bottom: 1px solid #eee;
}
.dark .spec-content h2 {
border-bottom-color: #333;
}
.spec-content h3 {
margin-top: 1.5em;
margin-bottom: 0.5em;
}
.spec-content p {
margin-bottom: 1em;
}
.spec-content ul,
.spec-content ol {
margin-bottom: 1em;
padding-left: 2em;
}
.spec-content li {
margin-bottom: 0.25em;
}
.spec-content a {
color: #1f8dd6;
text-decoration: none;
}
.spec-content a:hover {
text-decoration: underline;
}
.dark .spec-content a {
color: #4da6e8;
}
.spec-content img {
max-width: 100%;
height: auto;
margin: 1em 0;
}
.spec-content blockquote {
margin: 1em 0;
padding-left: 1em;
border-left: 4px solid #ddd;
color: #666;
}
.dark .spec-content blockquote {
border-left-color: #444;
color: #aaa;
}
.spec-content hr {
margin: 2em 0;
border: none;
border-top: 1px solid #eee;
}
.dark .spec-content hr {
border-top-color: #333;
}
}