@@ -181,13 +181,13 @@ function handleFootnote(data: string, separator: string) {
181181 }
182182 )
183183
184- return slides . join ( separator )
184+ return slides . join ( "\n---\n" )
185185}
186186
187187function handleIndex ( data : string , separator : string , option : SlideOptions , index : string ) {
188188 const slides = data . split ( separator )
189189
190- if ( ! option . index ) return slides . join ( "\n---\n" ) ;
190+ if ( ! option . index || ! index ) return slides . join ( separator ) ;
191191 slides . splice ( 1 , 0 , index )
192192
193193 const indexMap = new Map < string , number > ( )
@@ -223,14 +223,16 @@ function handleIndex(data: string, separator: string, option: SlideOptions, inde
223223 )
224224 }
225225
226- return slides . join ( "\n---\n" )
226+ return slides . join ( separator )
227227}
228228
229229function makeIndex ( ) {
230230
231231 const headers = document . querySelectorAll ( 'article.popover-hint h1[id]' ) ;
232232 const index = Array . from ( headers ) . map ( head => `<li><a data-href="${ head . textContent } " class="">${ head . textContent } </a></li>` ) . join ( '' )
233233
234+ if ( ! index ) return ""
235+
234236 return `
235237 <h1 class="slide-index-title">Index</h1>
236238 <ul class="slide-index-list" >
@@ -257,13 +259,15 @@ function appendRemark(option: SlideOptions) {
257259 anchorBlank (
258260 unwrapSlideNote (
259261 unwrapFootnotesSection (
260- handleIndex (
261- handleFootnote (
262+ handleFootnote (
263+ handleIndex (
262264 injectSeparators ( header + ( option . tags ? tags : "" ) + body , separator ) ,
263- separator
265+ separator ,
266+ option ,
267+ makeIndex ( )
264268 ) ,
265- separator , option , makeIndex ( )
266- )
269+ separator
270+ ) ,
267271 )
268272 )
269273 )
0 commit comments