mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 09:05:56 +00:00
BUGFIX: Fix anchor link URIs in the table of content nav
This commit is contained in:
parent
6ba14bed75
commit
3a5be64818
@ -1,7 +1,6 @@
|
||||
(function($) {
|
||||
$(document).ready(function() {
|
||||
|
||||
|
||||
/** -----------------------------------------------
|
||||
* TABLE OF CONTENTS
|
||||
*
|
||||
@ -9,10 +8,13 @@
|
||||
*/
|
||||
if($("#table-of-contents").length > 0) {
|
||||
var toc = '<div class="box"><ul id="toc"><h4>In this document:</h4>';
|
||||
|
||||
$('#left-column h1, #left-column h2, #left-column h3, #left-column h4').each(function(i) {
|
||||
|
||||
// Remove existing anchor redirection in the url
|
||||
var pageURL = window.location.href.replace(/#[a-zA-Z0-9\-\_]*/g, '');
|
||||
|
||||
$('#left-column h1[id], #left-column h2[id], #left-column h3[id], #left-column h4[id]').each(function(i) {
|
||||
var current = $(this);
|
||||
toc += '<li class="' + current.attr("tagName").toLowerCase() + '"><a id="link' + i + '" href="'+ window.location.href +'#title' + i + '" title="' + current.html() + '">' + current.html() + '</a></li>';
|
||||
toc += '<li class="' + current.attr("tagName").toLowerCase() + '"><a id="link' + i + '" href="'+ pageURL +'#' + $(this).attr('id') + '" title="' + current.html() + '">' + current.html() + '</a></li>';
|
||||
});
|
||||
|
||||
toc += '</ul></div>';
|
||||
@ -25,7 +27,7 @@
|
||||
*
|
||||
* Automatically adds anchor links to headings that have IDs
|
||||
*/
|
||||
$("h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]").each(function() {
|
||||
$("#left-column h1[id], #left-column h2[id], #left-column h3[id], #left-column h4[id], #left-column h5[id], #left-column h6[id]").each(function() {
|
||||
var link = '<a class="heading-anchor-link" title="Link to this section" href="#' + $(this).attr('id') + '">¶</a>';
|
||||
$(this).append(' ' + link);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user