@@ -140,6 +140,7 @@ def add_children(children)
140
140
current_page_html = '<h1 id="heading-one">Heading one</h1><h2 id="heading-two">Heading two</h2>' ;
141
141
142
142
config = {
143
+ http_prefix : "/" ,
143
144
tech_docs : {
144
145
max_toc_heading_level : 3
145
146
}
@@ -173,6 +174,55 @@ def add_children(children)
173
174
expect ( subject . multi_page_table_of_contents ( resources , current_page , config , current_page_html ) . strip ) . to eq ( expected_multi_page_table_of_contents . strip )
174
175
end
175
176
177
+ it 'builds a table of contents from several page resources with a custom http prefix ocnfigured' do
178
+ resources = [ ]
179
+ resources [ 0 ] = FakeResource . new ( '/prefix/index.html' , '<h1 id="heading-one">Heading one</h1><h2 id="heading-two">Heading two</h2>' , 10 , 'Index' ) ;
180
+ resources [ 1 ] = FakeResource . new ( '/prefix/a.html' , '<h1 id="heading-one">Heading one</h1><h2 id="heading-two">Heading two</h2>' , 10 , 'Sub page A' , resources [ 0 ] ) ;
181
+ resources [ 2 ] = FakeResource . new ( '/prefix/b.html' , '<h1 id="heading-one">Heading one</h1><h2 id="heading-two">Heading two</h2>' , 20 , 'Sub page B' , resources [ 0 ] ) ;
182
+ resources [ 0 ] . add_children [ resources [ 1 ] , resources [ 2 ] ]
183
+
184
+ current_page = double ( "current_page" ,
185
+ data : double ( "page_frontmatter" , description : "The description." , title : "The Title" ) ,
186
+ url : "/prefix/index.html" ,
187
+ metadata : { locals : { } } )
188
+
189
+ current_page_html = '<h1 id="heading-one">Heading one</h1><h2 id="heading-two">Heading two</h2>' ;
190
+
191
+ config = {
192
+ http_prefix : "/prefix" ,
193
+ tech_docs : {
194
+ max_toc_heading_level : 3
195
+ }
196
+ }
197
+
198
+ expected_multi_page_table_of_contents = %{
199
+ <ul><li><a href="/prefix/index.html">Index</a>
200
+ <ul>
201
+ <li>
202
+ <a href="/prefix/a.html#heading-one">Heading one</a>
203
+ <ul>
204
+ <li>
205
+ <a href="/prefix/a.html#heading-two">Heading two</a>
206
+ </li>
207
+ </ul>
208
+ </li>
209
+ </ul>
210
+ <ul>
211
+ <li>
212
+ <a href="/prefix/b.html#heading-one">Heading one</a>
213
+ <ul>
214
+ <li>
215
+ <a href="/prefix/b.html#heading-two">Heading two</a>
216
+ </li>
217
+ </ul>
218
+ </li>
219
+ </ul>
220
+ </li></ul>
221
+ }
222
+
223
+ expect ( subject . multi_page_table_of_contents ( resources , current_page , config , current_page_html ) . strip ) . to eq ( expected_multi_page_table_of_contents . strip )
224
+ end
225
+
176
226
it 'builds a table of contents from a single page resources' do
177
227
resources = [ ]
178
228
resources . push FakeResource . new ( '/index.html' , '<h1 id="heading-one">Heading one</h1><h2 id="heading-two">Heading two</h2><h1 id="heading-one">Heading one</h1><h2 id="heading-two">Heading two</h2><h1 id="heading-one">Heading one</h1><h2 id="heading-two">Heading two</h2>' ) ;
@@ -185,6 +235,7 @@ def add_children(children)
185
235
current_page_html = '<h1 id="heading-one">Heading one</h1><h2 id="heading-two">Heading two</h2><h1 id="heading-one">Heading one</h1><h2 id="heading-two">Heading two</h2><h1 id="heading-one">Heading one</h1><h2 id="heading-two">Heading two</h2>' ;
186
236
187
237
config = {
238
+ http_prefix : "/" ,
188
239
tech_docs : {
189
240
max_toc_heading_level : 3 ,
190
241
multipage_nav : true
0 commit comments