11// This file was automatically converted to ReScript from 'Markdown.re'
22// Check the output and make sure to delete the original file
3- external childrenToString : React .element => string = "%identity"
43
54module P = {
65 @react.component
@@ -110,15 +109,11 @@ module UrlBox = {
110109
111110// Used for creating invisible, hoverable <a> anchors for url linking
112111module Anchor = {
113- // Todo: Headers with nested components don't pass a string, we need to flatten
114- // everything to a single string first before we are able to use this id transformation
115- // function
116-
117112 @react.component
118- let make = (~id : string , ~title : string ) => {
119- <span className = "inline group relative" title >
113+ let make = (~id : string , ~title : option < string > = ? ) => {
114+ <span className = "inline group relative" title = ? title >
120115 <a
121- title
116+ title = ? title
122117 className = "scroll-mt-30 invisible text-gray-60 opacity-50 hover:opacity-100 hover:text-gray-60 hover:cursor-pointer group-hover:visible"
123118 href = {"#" ++ id }
124119 id = {id }
@@ -137,20 +132,14 @@ module H1 = {
137132
138133module H2 = {
139134 @react.component
140- let make = (~id , ~children ) => {
135+ let make = (~id , ~children , ~ title = ? ) => {
141136 // Children may not be a string
142- let title = {
143- try {
144- childrenToString (children )-> Url .normalizeAnchor
145- } catch {
146- | _ => ""
147- }
148- }
137+
149138 <>
150139 <h2 id className = "group mt-16 mb-3 hl-3 scroll-mt-32" >
151140 children
152141 <span className = "ml-2" >
153- <Anchor title = { title } id = { title } />
142+ <Anchor ? title id />
154143 </span >
155144 </h2 >
156145 </>
@@ -159,59 +148,38 @@ module H2 = {
159148
160149module H3 = {
161150 @react.component
162- let make = (~id , ~children ) => {
163- let title = {
164- try {
165- childrenToString (children )-> Url .normalizeAnchor
166- } catch {
167- | _ => ""
168- }
169- }
151+ let make = (~id , ~children , ~title = ?) => {
170152 <h3 id className = "group mt-8 mb-4 hl-4 scroll-mt-32" >
171153 children
172154 <span className = "ml-2" >
173- <Anchor title = { title } id = {title -> encodeURIComponent } />
155+ <Anchor ? title id = {id } />
174156 </span >
175157 </h3 >
176158 }
177159}
178160
179161module H4 = {
180162 @react.component
181- let make = (~id , ~children ) => {
182- let title = {
183- try {
184- childrenToString (children )-> Url .normalizeAnchor
185- } catch {
186- | _ => ""
187- }
188- }
163+ let make = (~id , ~children , ~title = ?) => {
189164 <h4 id className = "group mt-8 hl-5 scroll-mt-32" >
190165 children
191166 <span className = "ml-2" >
192- <Anchor title = { title } id = { title -> encodeURIComponent } />
167+ <Anchor ? title id />
193168 </span >
194169 </h4 >
195170 }
196171}
197172
198173module H5 = {
199174 @react.component
200- let make = (~id , ~children ) => {
201- let title = {
202- try {
203- childrenToString (children )-> Url .normalizeAnchor
204- } catch {
205- | _ => ""
206- }
207- }
175+ let make = (~id , ~children , ~title = ?) => {
208176 <h5
209177 id
210178 className = "group mt-12 mb-3 text-12 leading-2 font-sans font-semibold uppercase tracking-wide text-gray-80"
211179 >
212180 children
213181 <span className = "ml-2" >
214- <Anchor title = { title } id = { title -> encodeURIComponent } />
182+ <Anchor ? title id />
215183 </span >
216184 </h5 >
217185 }
0 commit comments