Skip to content

Commit 7b16750

Browse files
committed
normalize h3-h5
1 parent 0acbd3f commit 7b16750

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/components/Markdown.res

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,13 @@ module H2 = {
160160
module H3 = {
161161
@react.component
162162
let make = (~id, ~children) => {
163-
let title = childrenToString(children)
163+
let title = {
164+
try {
165+
childrenToString(children)->Url.normalizeAnchor
166+
} catch {
167+
| _ => ""
168+
}
169+
}
164170
<h3 id className="group mt-8 mb-4 hl-4 scroll-mt-32">
165171
children
166172
<span className="ml-2">
@@ -173,7 +179,13 @@ module H3 = {
173179
module H4 = {
174180
@react.component
175181
let make = (~id, ~children) => {
176-
let title = childrenToString(children)
182+
let title = {
183+
try {
184+
childrenToString(children)->Url.normalizeAnchor
185+
} catch {
186+
| _ => ""
187+
}
188+
}
177189
<h4 id className="group mt-8 hl-5 scroll-mt-32">
178190
children
179191
<span className="ml-2">
@@ -186,7 +198,13 @@ module H4 = {
186198
module H5 = {
187199
@react.component
188200
let make = (~id, ~children) => {
189-
let title = childrenToString(children)
201+
let title = {
202+
try {
203+
childrenToString(children)->Url.normalizeAnchor
204+
} catch {
205+
| _ => ""
206+
}
207+
}
190208
<h5
191209
id
192210
className="group mt-12 mb-3 text-12 leading-2 font-sans font-semibold uppercase tracking-wide text-gray-80"

0 commit comments

Comments
 (0)