diff --git a/system/includes/functions.php b/system/includes/functions.php
index 1e49d85..50cb0b1 100644
--- a/system/includes/functions.php
+++ b/system/includes/functions.php
@@ -533,7 +533,7 @@ function get_posts($posts, $page = 1, $perpage = 0)
});
EOF;
- $post->body = $toc['0'] . $load . '
' . $toc['1'];
+ $post->body = $toc['0'] . $load . '' . $toc['1'];
}
// Convert image tags to figures
@@ -600,6 +600,24 @@ function get_pages($pages, $page = 1, $perpage = 0)
// Get the contents and convert it to HTML
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
+ $toc = explode('', $post->body);
+ if (isset($toc['1'])) {
+ $load = <<
+ document.addEventListener("DOMContentLoaded", function() {
+ if (document.getElementById('toc-wrapper.page-{$post->slug}').parentNode.classList.contains('page-{$post->slug}')) {
+ generateTOC('.page-{$post->slug}');
+ } else {
+ document.getElementById('toc-wrapper.page-{$post->slug}').parentNode.classList.add('page-{$post->slug}');
+ generateTOC('.page-{$post->slug}');
+ }
+
+ });
+
+ EOF;
+ $post->body = $toc['0'] . $load . '' . $toc['1'];
+ }
+
if (config('views.counter') == 'true') {
$post->views = get_views('page_' . $post->slug, $post->file);
} else {
@@ -670,6 +688,24 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0)
// Get the contents and convert it to HTML
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
+ $toc = explode('', $post->body);
+ if (isset($toc['1'])) {
+ $load = <<
+ document.addEventListener("DOMContentLoaded", function() {
+ if (document.getElementById('toc-wrapper.subpage-{$post->slug}').parentNode.classList.contains('subpage-{$post->slug}')) {
+ generateTOC('.subpage-{$post->slug}');
+ } else {
+ document.getElementById('toc-wrapper.subpage-{$post->slug}').parentNode.classList.add('subpage-{$post->slug}');
+ generateTOC('.subpage-{$post->slug}');
+ }
+
+ });
+
+ EOF;
+ $post->body = $toc['0'] . $load . '' . $toc['1'];
+ }
+
if (config('views.counter') == 'true') {
$post->views = get_views('subpage_' . $post->parentSlug .'.'. $post->slug, $post->file);
} else {
@@ -946,6 +982,24 @@ function read_category_info($category)
// Get the contents and convert it to HTML
$desc->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
+
+ $toc = explode('', $desc->body);
+ if (isset($toc['1'])) {
+ $load = <<
+ document.addEventListener("DOMContentLoaded", function() {
+ if (document.getElementById('toc-wrapper.taxonomy-{$desc->slug}').parentNode.classList.contains('taxonomy-{$desc->slug}')) {
+ generateTOC('.taxonomy-{$desc->slug}');
+ } else {
+ document.getElementById('toc-wrapper.taxonomy-{$desc->slug}').parentNode.classList.add('taxonomy-{$desc->slug}');
+ generateTOC('.taxonomy-{$desc->slug}');
+ }
+
+ });
+
+ EOF;
+ $desc->body = $toc['0'] . $load . '' . $toc['1'];
+ }
$desc->description = get_content_tag("d", $content, get_description($desc->body));
@@ -1174,6 +1228,24 @@ function get_author($name)
// Get the contents and convert it to HTML
$author->about = MarkdownExtra::defaultTransform(remove_html_comments($content));
+ $toc = explode('', $author->about);
+ if (isset($toc['1'])) {
+ $load = <<
+ document.addEventListener("DOMContentLoaded", function() {
+ if (document.getElementById('toc-wrapper.profile-{$author->slug}').parentNode.classList.contains('profile-{$author->slug}')) {
+ generateTOC('.profile-{$author->slug}');
+ } else {
+ document.getElementById('toc-wrapper.profile-{$author->slug}').parentNode.classList.add('profile-{$author->slug}');
+ generateTOC('.profile-{$author->slug}');
+ }
+
+ });
+
+ EOF;
+ $author->about = $toc['0'] . $load . '' . $toc['1'];
+ }
+
$author->body = $author->about;
$author->title = $author->name;
@@ -1223,6 +1295,23 @@ function get_frontpage()
$front->url = site_url() . 'front';
// Get the contents and convert it to HTML
$front->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
+ $toc = explode('', $front->body);
+ if (isset($toc['1'])) {
+ $load = <<
+ document.addEventListener("DOMContentLoaded", function() {
+ if (document.getElementById('toc-wrapper.page-front').parentNode.classList.contains('page-front')) {
+ generateTOC('.page-front');
+ } else {
+ document.getElementById('toc-wrapper.page-front').parentNode.classList.add('page-front');
+ generateTOC('.page-front');
+ }
+
+ });
+
+ EOF;
+ $front->body = $toc['0'] . $load . '' . $toc['1'];
+ }
} else {
$front->title = 'Welcome';
$front->url = site_url() . 'front';