mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-19 10:44:38 -04:00
Fix js for toc
This commit is contained in:
parent
7768124fb2
commit
ed50c7dbd0
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
title: The Benefits of Static
|
title: The Benefits of Static
|
||||||
linktitle: Benefits of Static
|
linktitle: The Benefits of Static
|
||||||
description:
|
description:
|
||||||
date: 2017-02-01
|
date: 2017-02-01
|
||||||
publishdate: 2017-02-01
|
publishdate: 2017-02-01
|
||||||
|
@ -5,10 +5,9 @@ description:
|
|||||||
date: 2017-02-01
|
date: 2017-02-01
|
||||||
publishdate: 2017-02-01
|
publishdate: 2017-02-01
|
||||||
lastmod: 2017-02-01
|
lastmod: 2017-02-01
|
||||||
|
tags: [wercker]
|
||||||
weight:
|
weight:
|
||||||
draft: false
|
draft: false
|
||||||
type:
|
|
||||||
layout:
|
|
||||||
slug:
|
slug:
|
||||||
aliases: []
|
aliases: []
|
||||||
notes:
|
notes:
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
//removes toc if not enough headings
|
//removes toc if not enough headings
|
||||||
(function() {
|
(function() {
|
||||||
let tocLinks = document.querySelectorAll('#TableOfContents > ul a');
|
let tocLinks = document.querySelectorAll('#TableOfContents > ul a');
|
||||||
if(tocLinks && tocLinks.length < 2){
|
let toc = document.getElementById('toc');
|
||||||
document.getElementById('toc').remove();
|
console.log(tocLinks);
|
||||||
}else if (tocLinks && tocLinks.length > 1){
|
if (toc && (tocLinks.length < 2)) {
|
||||||
document.getElementById('toc-toggle').addEventListener('click',toggleToc,false);
|
toc.remove();
|
||||||
|
} else if (tocLinks.length > 1) {
|
||||||
|
document.getElementById('toc-toggle').addEventListener('click', toggleToc, false);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
function toggleToc(evt) {
|
function toggleToc(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
console.log("hello");
|
console.log("hello");
|
||||||
document.getElementById('toc').classList.toggle('toc-open');
|
document.getElementById('toc').classList.toggle('toc-open');
|
||||||
document.getElementById('toc-toggle').classList.toggle('toc-open');
|
document.getElementById('toc-toggle').classList.toggle('toc-open');
|
||||||
}
|
}
|
||||||
|
2
themes/hugodocs/static/js/script.min.js
vendored
2
themes/hugodocs/static/js/script.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user