File tree 2 files changed +8
-2
lines changed
src/renderer/html_handlebars
2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ impl HtmlHandlebars {
116
116
if ctx. is_index {
117
117
ctx. data . insert ( "path" . to_owned ( ) , json ! ( "index.md" ) ) ;
118
118
ctx. data . insert ( "path_to_root" . to_owned ( ) , json ! ( "" ) ) ;
119
- ctx. data . insert ( "is_index" . to_owned ( ) , json ! ( " true" ) ) ;
119
+ ctx. data . insert ( "is_index" . to_owned ( ) , json ! ( true ) ) ;
120
120
let rendered_index = ctx. handlebars . render ( "index" , & ctx. data ) ?;
121
121
let rendered_index =
122
122
self . post_process ( rendered_index, & ctx. html_config . playground , ctx. edition ) ;
Original file line number Diff line number Diff line change @@ -57,6 +57,11 @@ impl HelperDef for RenderToc {
57
57
out. write ( "<ol class=\" chapter\" >" ) ?;
58
58
59
59
let mut current_level = 1 ;
60
+ // The "index" page, which has this attribute set, is supposed to alias the first chapter in
61
+ // the book, i.e. the first link. There seems to be no easy way to determine which chapter
62
+ // the "index" is aliasing from within the renderer, so this is used instead to force the
63
+ // first link to be active. See further below.
64
+ let mut is_first_chapter = ctx. data ( ) . get ( "is_index" ) . is_some ( ) ;
60
65
61
66
for item in chapters {
62
67
// Spacer
@@ -130,7 +135,8 @@ impl HelperDef for RenderToc {
130
135
out. write ( & tmp) ?;
131
136
out. write ( "\" " ) ?;
132
137
133
- if path == & current_path {
138
+ if path == & current_path || is_first_chapter {
139
+ is_first_chapter = false ;
134
140
out. write ( " class=\" active\" " ) ?;
135
141
}
136
142
You can’t perform that action at this time.
0 commit comments