Use the jquery.toc.js library to auto-generate a table of contents for the loaded page under the side nav menu

This commit is contained in:
Andrew Manning 2016-11-27 21:25:38 -07:00
parent 678239424a
commit 5bcb373c00
3 changed files with 35 additions and 26 deletions

View File

@ -93,29 +93,38 @@
</div> </div>
</div> </div>
<div id="page-toc-container" style="margin-top:1.0em;">
<h3>Contents</h3>
</div>
<script> <script>
// $(document).ready(function() {
// Determine the content section from the URL and expand the appropriate menu section // Determine the content section from the URL and expand the appropriate menu section
var url = document.createElement('a'); var url = document.createElement('a');
url.href = window.location; url.href = window.location;
switch (url.pathname.split('/')[2]) { switch (url.pathname.split('/')[2]) {
case 'tutorials': case 'tutorials':
$('#tutorials').addClass('in'); $('#tutorials').addClass('in');
break; break;
case 'about': case 'about':
$('#about').addClass('in'); $('#about').addClass('in');
break; break;
case 'admin': case 'admin':
$('#administrators').addClass('in'); $('#administrators').addClass('in');
break; break;
case 'member': case 'member':
$('#members').addClass('in'); $('#members').addClass('in');
break; break;
case 'developer': case 'developer':
$('#developers').addClass('in'); $('#developers').addClass('in');
break; break;
default: default:
break; break;
} }
// } $(document).ready(function () {
var tocUl = $('#page-toc-container').append('<ul>').find('ul');
tocUl.removeClass();
tocUl.toc({content: "#doco-content", headings: "h1,h2,h3,h4"});
});
</script> </script>

View File

@ -2,7 +2,7 @@
<div class="section-title-wrapper"> <div class="section-title-wrapper">
<h2>{{$title}}</h2> <h2>{{$title}}</h2>
</div> </div>
<div class="section-content-wrapper"> <div class="section-content-wrapper" id="doco-content">
{{$content}} {{$content}}
</div> </div>
</div> </div>