Skip to content

Commit 8b31074

Browse files
Merge pull request #1 from ComputelessComputer/codex/prose-heading-hierarchy
Improve prose heading hierarchy
2 parents 630c570 + 6ff4945 commit 8b31074

1 file changed

Lines changed: 70 additions & 4 deletions

File tree

src/layouts/Base.astro

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const { title } = Astro.props;
2323
<style is:global>
2424
:root {
2525
--max-width: 640px;
26+
--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
27+
--font-serif: "Instrument Serif", serif;
2628
--font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
2729
}
2830

@@ -39,7 +41,7 @@ const { title } = Astro.props;
3941
overflow-y: scroll;
4042
}
4143
body {
42-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
44+
font-family: var(--font-sans);
4345
line-height: 1.6;
4446
color: #1a1a1a;
4547
max-width: var(--max-width);
@@ -61,22 +63,86 @@ const { title } = Astro.props;
6163
}
6264

6365
h1 {
64-
font-family: "Instrument Serif", serif;
66+
font-family: var(--font-serif);
6567
font-style: italic;
6668
font-size: 2.25rem;
6769
font-weight: 400;
6870
}
6971
h2 {
70-
font-family: "Instrument Serif", serif;
72+
font-family: var(--font-serif);
7173
font-size: 1.5rem;
7274
font-weight: 400;
7375
}
7476
h3 {
75-
font-family: "Instrument Serif", serif;
77+
font-family: var(--font-serif);
7678
font-size: 1.25rem;
7779
font-weight: 400;
7880
}
7981

82+
.prose :is(h2, h3, h4, h5, h6) {
83+
scroll-margin-top: 1.5rem;
84+
text-wrap: balance;
85+
}
86+
87+
.prose :is(h2, h3) {
88+
font-family: var(--font-serif);
89+
font-weight: 400;
90+
letter-spacing: -0.02em;
91+
line-height: 1.05;
92+
}
93+
94+
.prose h2 {
95+
font-size: clamp(1.9rem, 4vw, 2.3rem);
96+
margin-top: 3rem;
97+
margin-bottom: 0.9rem;
98+
}
99+
100+
.prose h3 {
101+
font-size: clamp(1.7rem, 3vw, 2rem);
102+
margin-top: 2.75rem;
103+
margin-bottom: 0.85rem;
104+
}
105+
106+
.prose hr + :is(h2, h3) {
107+
margin-top: 0;
108+
}
109+
110+
.prose h4 {
111+
margin-top: 1.9rem;
112+
margin-bottom: 0.55rem;
113+
font-size: 1.25rem;
114+
font-weight: 700;
115+
letter-spacing: -0.015em;
116+
line-height: 1.25;
117+
}
118+
119+
.prose h5 {
120+
margin-top: 1.65rem;
121+
margin-bottom: 0.55rem;
122+
font-size: 1.05rem;
123+
font-weight: 700;
124+
line-height: 1.35;
125+
}
126+
127+
.prose h6 {
128+
margin-top: 1.85rem;
129+
margin-bottom: 0.7rem;
130+
font-size: 0.95rem;
131+
font-weight: 700;
132+
letter-spacing: -0.01em;
133+
line-height: 1.4;
134+
color: #38322b;
135+
}
136+
137+
.prose h6::before {
138+
content: "";
139+
display: block;
140+
width: 2.75rem;
141+
height: 1px;
142+
margin-bottom: 0.45rem;
143+
background: linear-gradient(90deg, #1a1a1a 0%, rgba(26, 26, 26, 0) 100%);
144+
}
145+
80146
p {
81147
margin-bottom: 1em;
82148
}

0 commit comments

Comments
 (0)