Skip to content

Commit

Permalink
Add TOC and header anchors back in
Browse files Browse the repository at this point in the history
  • Loading branch information
dreverri committed Feb 16, 2011
1 parent d56c528 commit dcb2f26
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions _Layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ <h1>{{ page.title }}</h1>
<!-- scripts concatenated and minified via ant build script-->
<script src="http://www.basho.com/js/plugins.js"></script>
<script src="http://www.basho.com/js/script.js"></script>
<script src="{{ wiki.base_path }}js/wiki_specific.js"></script>
<!-- end concatenated and minified scripts-->

<script type="text/javascript" language="javascript" src="http://www.basho.com/js/jquery.dropdownPlain.js"></script>
Expand Down
25 changes: 25 additions & 0 deletions js/wiki_specific.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(function($){
var cname = function(name) {
return name.replace(/[ \/<>]/g, '-');
}

var list;
if ( $("#toc").length ) {
list = $("<ul />");
$("#toc").append(list);
}


// Anchor all headers
$(":header:not(h1)").each(function(i) {
var current = $(this);
var text = current.text();
var id = cname(text);
current.attr("id", id);
current.append(' <a class=\"toc-anchor\" href=\"#' + encodeURIComponent(id) + '\">#</a>');
if(current.is("h2") && list){
list.append("<li><a href=\"#" + encodeURIComponent(id) + "\">" + text + "</a></li>");
}
});

})(jQuery);

0 comments on commit dcb2f26

Please sign in to comment.