@@ -140,6 +140,7 @@ def add_children(children)
140140 current_page_html = '<h1 id="heading-one">Heading one</h1><h2 id="heading-two">Heading two</h2>' ;
141141
142142 config = {
143+ http_prefix : "/" ,
143144 tech_docs : {
144145 max_toc_heading_level : 3
145146 }
@@ -173,6 +174,55 @@ def add_children(children)
173174 expect ( subject . multi_page_table_of_contents ( resources , current_page , config , current_page_html ) . strip ) . to eq ( expected_multi_page_table_of_contents . strip )
174175 end
175176
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+
176226 it 'builds a table of contents from a single page resources' do
177227 resources = [ ]
178228 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)
185235 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>' ;
186236
187237 config = {
238+ http_prefix : "/" ,
188239 tech_docs : {
189240 max_toc_heading_level : 3 ,
190241 multipage_nav : true
0 commit comments