mirror of
https://github.com/jimeh/commonflow.org.git
synced 2026-02-19 05:46:40 +00:00
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:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user