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,8 +93,12 @@
</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;
@ -117,5 +121,10 @@
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>