File tree Expand file tree Collapse file tree 4 files changed +38
-16
lines changed Expand file tree Collapse file tree 4 files changed +38
-16
lines changed Original file line number Diff line number Diff line change 28
28
#md-page-menu a.active {
29
29
/* background-color: rgba(0, 0, 0, 0.01); */
30
30
font-weight: bold;
31
- padding-left: 6px;
32
-
33
31
}
34
32
@media (min-width: 992px) {
35
33
#md-page-menu.affix {
Original file line number Diff line number Diff line change 193
193
194
194
// adds a link to the navigation at the top of the page
195
195
function addJumpLinkToTOC ( $heading ) {
196
- if ( $ . md . config . useSideMenu === false ) return ;
197
- if ( $heading . prop ( "tagName" ) !== 'H2' ) return ;
196
+ if ( $ . md . config . pageMenu && $ . md . config . pageMenu . disable !== false ) return ;
197
+
198
+ function supportedHeading ( heading ) {
199
+ var autoAnchors = $ . md . config . pageMenu . useHeadings . split ( ',' ) ;
200
+ var supported = false ;
201
+
202
+ $ ( autoAnchors ) . each ( function ( i , e ) {
203
+ if ( heading . toLowerCase ( ) === e . toLowerCase ( ) ) {
204
+ supported = true ;
205
+ }
206
+ } ) ;
207
+
208
+ return supported ;
209
+ }
210
+
211
+ if ( ! supportedHeading ( $heading . prop ( "tagName" ) ) ) return ;
212
+
213
+ var c = $ . md . config . pageMenu . returnAnchor ;
198
214
199
- var c = $ . md . config . tocAnchor ;
200
215
if ( c === '' )
201
216
return ;
202
217
Original file line number Diff line number Diff line change 240
240
}
241
241
242
242
function createPageContentMenu ( ) {
243
-
244
243
// assemble the menu
245
- var $headings = $ ( '#md-content' ) . find ( 'h2' ) . clone ( ) ;
246
- // we dont want the text of any child nodes
244
+ var $headings = $ ( '#md-content' ) . find ( $ . md . config . pageMenu . useHeadings ) ;
245
+
247
246
$headings . children ( ) . remove ( ) ;
248
247
249
248
if ( $headings . length <= 1 ) {
300
299
var $ul = $pannel . find ( "ul" ) ;
301
300
affixDiv . append ( $pannel ) ;
302
301
303
- $headings . each ( function ( i , e ) {
304
- var $heading = $ ( e ) ;
305
- var $li = $ ( '<li class="list-group-item" />' ) ;
306
- var $a = $ ( '<a />' ) ;
302
+ function createMenuItem ( heading , className ) {
303
+ var $heading = $ ( heading ) ;
304
+ var $a = $ ( '<a class="list-group-item" />' ) ;
305
+ $a . addClass ( className ) ;
307
306
$a . attr ( 'href' , $ . md . util . getInpageAnchorHref ( $heading . toptext ( ) ) ) ;
308
307
$a . click ( function ( ev ) {
309
308
ev . preventDefault ( ) ;
313
312
$ . md . scrollToInPageAnchor ( anchortext ) ;
314
313
} ) ;
315
314
$a . text ( $heading . toptext ( ) ) ;
316
- $li . append ( $a ) ;
317
- $ul . append ( $li ) ;
315
+ return $a ;
316
+ }
317
+
318
+ $ ( $headings ) . each ( function ( i , e ) {
319
+ var hClass = $ ( e ) . prop ( 'tagName' ) ;
320
+ var currLevel = parseInt ( hClass . substr ( 1 , 1 ) , 10 ) ;
321
+ var $hli = createMenuItem ( e , hClass . toLowerCase ( ) + '-nav' ) ;
322
+
323
+ $ul . append ( $hli ) ;
318
324
} ) ;
319
325
320
326
$ ( window ) . resize ( function ( ) {
Original file line number Diff line number Diff line change 18
18
// default config
19
19
$ . md . config = {
20
20
title : null ,
21
- useSideMenu : true ,
22
21
lineBreaks : 'gfm' ,
23
22
additionalFooterText : '' ,
24
23
anchorCharacter : '¶' ,
25
- tocAnchor : '[ ↑ ]'
24
+ pageMenu : {
25
+ disable : false ,
26
+ returnAnchor : "[top]" ,
27
+ useHeadings : "h2"
28
+ }
26
29
} ;
27
30
28
31
You can’t perform that action at this time.
0 commit comments