diff --git a/system/includes/functions.php b/system/includes/functions.php index c48703d..f483c35 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -521,9 +521,13 @@ function get_posts($posts, $page = 1, $perpage = 0) $toc = explode('', $post->body); if (isset($toc['1'])) { $load = <<window.onload = function () {generateTOC('.post-{$post->date}');}; + EOF; - $post->body = $toc['0'] . $load . '' . $toc['1']; + $post->body = $toc['0'] . $load . '' . $toc['1']; } // Convert image tags to figures diff --git a/system/resources/js/toc.js b/system/resources/js/toc.js index 0246c54..2b9169b 100644 --- a/system/resources/js/toc.js +++ b/system/resources/js/toc.js @@ -27,9 +27,9 @@ */ function generateTOC (id) { var documentRef = document; - var selector = id + ' h1,' + id + ' h2,' + id + ' h3,' + id + ' h4,' + id + ' h5,' + id + ' h6'; - var toc = documentRef.getElementById('toc'); - var headings = [].slice.call(documentRef.body.querySelectorAll(selector)); + var selector = id + ' h1,' + id + ' h2,' + id + ' h3,' + id + ' h4,' + id + ' h5,' + id + ' h6'; + var toc = documentRef.getElementById('toc' + id); + var headings = [].slice.call(documentRef.body.querySelectorAll(selector)); if (headings && headings.length) { headings.forEach(function (heading, index) { heading.setAttribute('id', 'toc-' + heading.textContent.replace(/\s+/g, '-').toLowerCase()); @@ -47,11 +47,11 @@ function generateTOC (id) { var div = documentRef.createElement('div'); div.setAttribute('class', heading.tagName.toLowerCase() + '-toc'); - heading.appendChild(anchor); - div.appendChild(link); - toc.appendChild(div); + heading.appendChild(anchor); + div.appendChild(link); + toc.appendChild(div); }); - documentRef.getElementById('toc-wrapper').style.display = 'inline-block'; + documentRef.getElementById('toc-wrapper' + id).style.display = 'inline-block'; } if (window.location.hash) { diff --git a/themes/blog/main.html.php b/themes/blog/main.html.php index 4500922..b5fb8f4 100644 --- a/themes/blog/main.html.php +++ b/themes/blog/main.html.php @@ -60,7 +60,7 @@ Edit'; } ?>

-
+
body, $p->url) ?>
diff --git a/themes/clean/main.html.php b/themes/clean/main.html.php index 4b3ca99..9220f2d 100644 --- a/themes/clean/main.html.php +++ b/themes/clean/main.html.php @@ -49,7 +49,7 @@
quote ?>
-
+
body) ?> body, $p->url) ?> diff --git a/themes/logs/main.html.php b/themes/logs/main.html.php index 284fa76..26ee850 100644 --- a/themes/logs/main.html.php +++ b/themes/logs/main.html.php @@ -49,7 +49,7 @@
quote ?>
-
+
body) ?> body, $p->url) ?> diff --git a/themes/readable/main.html.php b/themes/readable/main.html.php index 168c638..d11539f 100644 --- a/themes/readable/main.html.php +++ b/themes/readable/main.html.php @@ -49,7 +49,7 @@
quote ?>
-
+
body) ?> body, $p->url) ?> diff --git a/themes/twentyfifteen/main.html.php b/themes/twentyfifteen/main.html.php index 8da2ee6..6e2735c 100644 --- a/themes/twentyfifteen/main.html.php +++ b/themes/twentyfifteen/main.html.php @@ -61,7 +61,7 @@

title; ?>

-
+
body, $p->url); ?>
diff --git a/themes/twentysixteen/main.html.php b/themes/twentysixteen/main.html.php index 772aefb..b95772d 100644 --- a/themes/twentysixteen/main.html.php +++ b/themes/twentysixteen/main.html.php @@ -46,7 +46,7 @@
-
+
quote)):?>