Skip to content

Commit b32741e

Browse files
feat(website): add syntax highlighting to How It Works section
1 parent b2528fc commit b32741e

File tree

1 file changed

+72
-3
lines changed

1 file changed

+72
-3
lines changed

website/components/HowItWorks.tsx

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,57 @@
11
"use client";
22

3+
import { Highlight, type PrismTheme } from "prism-react-renderer";
4+
5+
// Custom theme matching site colors (same as Quickstart)
6+
const customTheme: PrismTheme = {
7+
plain: {
8+
color: "#F5F0E8", // warm cream
9+
backgroundColor: "#3D2B1F", // chocolate brown
10+
},
11+
styles: [
12+
{
13+
types: ["comment", "prolog", "doctype", "cdata"],
14+
style: { color: "#A89F91", fontStyle: "italic" as const },
15+
},
16+
{
17+
types: ["punctuation"],
18+
style: { color: "#D4A574" }, // muted gold
19+
},
20+
{
21+
types: ["property", "tag", "boolean", "number", "constant", "symbol"],
22+
style: { color: "#E8B87D" }, // mustard gold
23+
},
24+
{
25+
types: ["selector", "attr-name", "string", "char", "builtin", "inserted"],
26+
style: { color: "#E07B5E" }, // burnt sienna / coral
27+
},
28+
{
29+
types: ["atrule", "attr-value", "keyword"],
30+
style: { color: "#8ECAE6" }, // soft blue
31+
},
32+
{
33+
types: ["function", "class-name"],
34+
style: { color: "#F4D35E" }, // bright gold
35+
},
36+
{
37+
types: ["regex", "important", "variable"],
38+
style: { color: "#95D5B2" }, // mint green
39+
},
40+
{
41+
types: ["title"],
42+
style: { color: "#F4D35E", fontWeight: "bold" as const }, // headers in gold
43+
},
44+
{
45+
types: ["bold"],
46+
style: { fontWeight: "bold" as const },
47+
},
48+
{
49+
types: ["italic"],
50+
style: { fontStyle: "italic" as const },
51+
},
52+
],
53+
};
54+
355
export default function HowItWorks() {
456
const workflowCode = `# .github/workflows/stringly-typed.yml
557
name: Stringly-Typed
@@ -47,9 +99,26 @@ jobs:
4799
stringly-typed.yml
48100
</span>
49101
</div>
50-
<pre className="bg-[var(--chocolate-brown)] p-4 text-sm font-mono text-[var(--warm-cream)] overflow-x-auto leading-relaxed">
51-
<code>{workflowCode}</code>
52-
</pre>
102+
<Highlight
103+
theme={customTheme}
104+
code={workflowCode}
105+
language="yaml"
106+
>
107+
{({ className, style, tokens, getLineProps, getTokenProps }) => (
108+
<pre
109+
className={`${className} p-4 text-sm font-mono overflow-x-auto leading-relaxed`}
110+
style={style}
111+
>
112+
{tokens.map((line, i) => (
113+
<div key={i} {...getLineProps({ line })}>
114+
{line.map((token, key) => (
115+
<span key={key} {...getTokenProps({ token })} />
116+
))}
117+
</div>
118+
))}
119+
</pre>
120+
)}
121+
</Highlight>
53122
</div>
54123
</div>
55124

0 commit comments

Comments
 (0)