From 0c3561a708aa36576ed4c158197c1b4c6ee0a7d9 Mon Sep 17 00:00:00 2001 From: bedroesb Date: Fri, 23 Aug 2024 14:59:56 +0200 Subject: [PATCH] bugfix when no headings are present --- assets/js/toc.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/assets/js/toc.js b/assets/js/toc.js index 2941a3e..ab4cd19 100644 --- a/assets/js/toc.js +++ b/assets/js/toc.js @@ -1,4 +1,4 @@ -// https://github.com/ghiculescu/jekyll-table-of-contents +// Modified from: https://github.com/ghiculescu/jekyll-table-of-contents (function ($) { $.fn.toc = function (options) { var defaults = { @@ -37,13 +37,14 @@ } return this.id; }), output = $(this); + + // Check if there are any headers if (!headers.length || headers.length < settings.minimumHeaders || !output.length) { $('#main').removeClass("add-grid"); $("#toc").hide(); - - } - + return; // Exit early if there are no headers + } if (0 === settings.showSpeed) { settings.showEffect = 'none';