aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/js/even.js18
-rw-r--r--src/js/main.js1
-rw-r--r--src/package.json2
3 files changed, 17 insertions, 4 deletions
diff --git a/src/js/even.js b/src/js/even.js
index 8aa8459..87494c4 100644
--- a/src/js/even.js
+++ b/src/js/even.js
@@ -48,7 +48,7 @@ Even.mobileNavbar = function () {
})
}
-Even.toc = function () {
+Even._initToc = function () {
var SPACING = 20
var $toc = $('.post-toc')
var $footer = $('.post-footer')
@@ -152,7 +152,21 @@ Even.highlight = function () {
}
}
-Even.beforeToc = function () {
+Even.toc = function () {
+ const tocContainer = document.getElementById('post-toc')
+ if (tocContainer !== null) {
+ const toc = document.getElementById('TableOfContents')
+ if (toc === null) {
+ // toc = true, but there are no headings
+ tocContainer.parentNode.removeChild(tocContainer)
+ } else {
+ this._linkToc()
+ this._initToc()
+ }
+ }
+}
+
+Even._linkToc = function () {
const links = document.querySelectorAll('#TableOfContents a')
for (let i = 0; i < links.length; i++) links[i].className += ' toc-link'
diff --git a/src/js/main.js b/src/js/main.js
index 6539cf2..1764dfd 100644
--- a/src/js/main.js
+++ b/src/js/main.js
@@ -5,7 +5,6 @@ import '../css/style.scss'
$(document).ready(function () {
Even.backToTop()
Even.mobileNavbar()
- Even.beforeToc()
Even.toc()
Even.fancybox()
})
diff --git a/src/package.json b/src/package.json
index d44cdaa..2a9fa73 100644
--- a/src/package.json
+++ b/src/package.json
@@ -1,6 +1,6 @@
{
"name": "even-src",
- "version": "2.6.2",
+ "version": "2.6.3",
"description": "even source file",
"main": "index.js",
"scripts": {