Improved the TOC.
Automatically hide TOC titles
This commit is contained in:
parent
a76e41a5dc
commit
cf4a7f2e2f
3 changed files with 16 additions and 1 deletions
|
@ -100,12 +100,13 @@ layout: default
|
||||||
{% if site.toc and page.toc %}
|
{% if site.toc and page.toc %}
|
||||||
<div id="toc-wrap" class="topbar-down pr-4">
|
<div id="toc-wrap" class="topbar-down pr-4">
|
||||||
<h3 data-toc-skip class="pl-3 pt-2">
|
<h3 data-toc-skip class="pl-3 pt-2">
|
||||||
{{ site.data.label.panel.toc }}
|
{{- site.data.label.panel.toc -}}
|
||||||
</h3>
|
</h3>
|
||||||
<nav id="toc" data-toggle="toc"></nav>
|
<nav id="toc" data-toggle="toc"></nav>
|
||||||
</div>
|
</div>
|
||||||
<link rel="stylesheet" href="{{ site.baseurl }}/assets/lib/bootstrap-toc-1.0.1/bootstrap-toc.min.css" />
|
<link rel="stylesheet" href="{{ site.baseurl }}/assets/lib/bootstrap-toc-1.0.1/bootstrap-toc.min.css" />
|
||||||
<script src="{{ site.baseurl }}/assets/lib/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script>
|
<script src="{{ site.baseurl }}/assets/lib/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script>
|
||||||
|
<script src="{{ site.baseurl }}/assets/js/dist/toc.min.js"></script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div> <!-- #post-panel -->
|
</div> <!-- #post-panel -->
|
||||||
|
|
||||||
|
|
13
assets/js/_src/toc.js
Normal file
13
assets/js/_src/toc.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
/*
|
||||||
|
* Hide the empty ToC in posts.
|
||||||
|
*
|
||||||
|
* © 2019 Cotes Chung
|
||||||
|
* MIT Licensed
|
||||||
|
*/
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
// Hide ToC title if there is no head
|
||||||
|
if ($("#toc-wrap>nav#toc>ul>li").length == 0) {
|
||||||
|
$("#toc-wrap>h3").addClass("hidden");
|
||||||
|
}
|
||||||
|
});
|
1
assets/js/dist/toc.min.js
vendored
Normal file
1
assets/js/dist/toc.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
$(function(){if($("#toc-wrap>nav#toc>ul>li").length==0){$("#toc-wrap>h3").addClass("hidden")}});
|
Loading…
Reference in a new issue