Skip to content

Commit c5d9eaf

Browse files
rustyconoverclaude
andcommitted
docs: fix homepage code example highlighting
The hand-rolled <span> markup only colored 5 token types, and the un-marked text inherited the page's brown body color — Starlight's `.sl-markdown-content pre code` rule (color: unset) outranks the component's color, so most of the example rendered dark-on-dark-green. Replace the manual markup with Starlight's <Code> component so the example uses the same farm-theme Expressive Code highlighting as every other code block. Also fix the fake terminal's command text, which hit the same inherited-color issue. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6a281ed commit c5d9eaf

1 file changed

Lines changed: 20 additions & 36 deletions

File tree

docs/src/components/HomepageContent.astro

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
---
22
// Simplified homepage — prose-first, one code example, one terminal proof.
3+
import { Code } from "@astrojs/starlight/components";
4+
5+
const serverExample = `const protocol = new Protocol("Calculator");
6+
7+
protocol.unary("add", {
8+
params: { a: float, b: float },
9+
result: { result: float },
10+
handler: async ({ a, b }) => ({ result: a + b }),
11+
});
12+
13+
new VgiRpcServer(protocol).run();`;
314
---
415

516
<section class="home-content">
@@ -21,17 +32,7 @@
2132

2233
<div class="code-section">
2334
<p class="code-label">A complete RPC server in 8 lines</p>
24-
<div class="code-block">
25-
<pre><code><span class="kw">const</span> protocol = <span class="kw">new</span> <span class="cls">Protocol</span>(<span class="str">"Calculator"</span>);
26-
27-
protocol.<span class="fn">unary</span>(<span class="str">"add"</span>, {'{'}
28-
params: {'{'} a: <span class="typ">float</span>, b: <span class="typ">float</span> {'}'},
29-
result: {'{'} result: <span class="typ">float</span> {'}'},
30-
handler: <span class="kw">async</span> ({'{'} a, b {'}'}) =&gt; ({'{'} result: a + b {'}'}),
31-
{'}'});
32-
33-
<span class="kw">new</span> <span class="cls">VgiRpcServer</span>(protocol).<span class="fn">run</span>();</code></pre>
34-
</div>
35+
<Code code={serverExample} lang="ts" />
3536
</div>
3637

3738
<div class="terminal-section">
@@ -95,31 +96,11 @@ protocol.<span class="fn">unary</span>(<span class="str">"add"</span>, {'{'}
9596
letter-spacing: 0.05em;
9697
font-weight: 500;
9798
}
98-
.code-block {
99-
border-radius: 0.75rem;
100-
overflow: hidden;
101-
border: 1px solid #2d5016;
102-
background: #0d2818;
103-
}
104-
.code-block pre {
99+
/* The code example renders via Starlight's <Code> component, which uses
100+
the shared "farm-theme" Expressive Code config — no hand-rolled markup. */
101+
.code-section :global(.expressive-code) {
105102
margin: 0;
106-
padding: 1.5rem;
107-
overflow-x: auto;
108-
font-size: 0.875rem;
109-
line-height: 1.7;
110103
}
111-
.code-block code {
112-
font-family: var(--__sl-font-mono);
113-
background: none;
114-
color: #e8f5e9;
115-
}
116-
117-
/* ── Syntax colors (query.farm "farm-theme") ── */
118-
.kw { color: #66bb6a; font-weight: 700; }
119-
.cls { color: #fff59d; }
120-
.fn { color: #ffeb3b; }
121-
.str { color: #c5e1a5; }
122-
.typ { color: #fff59d; }
123104

124105
/* ── Terminal proof ── */
125106
.terminal-section {
@@ -153,11 +134,14 @@ protocol.<span class="fn">unary</span>(<span class="str">"add"</span>, {'{'}
153134
padding: 1rem 1.25rem;
154135
font-size: 0.8125rem;
155136
line-height: 1.7;
137+
background: transparent;
156138
}
157-
.terminal code {
139+
/* Beat Starlight's `.sl-markdown-content pre code` color rule so the
140+
un-marked command text isn't inherited dark on the dark-green terminal. */
141+
.terminal pre code {
158142
font-family: var(--__sl-font-mono);
159143
background: none;
160-
color: #e8f5e9;
144+
color: #e8f5e9 !important;
161145
}
162146
.prompt { color: #66bb6a; font-weight: 700; }
163147
.out { color: #c5e1a5; }

0 commit comments

Comments
 (0)