1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2026-05-07 17:28:39 +00:00

Improved the TOC.

Automatically hide TOC titles
This commit is contained in:
Cotes Chung
2019-10-08 19:58:17 +08:00
parent a76e41a5dc
commit cf4a7f2e2f
3 changed files with 16 additions and 1 deletions
+2 -1
View File
@@ -100,12 +100,13 @@ layout: default
{% if site.toc and page.toc %}
<div id="toc-wrap" class="topbar-down pr-4">
<h3 data-toc-skip class="pl-3 pt-2">
{{ site.data.label.panel.toc }}
{{- site.data.label.panel.toc -}}
</h3>
<nav id="toc" data-toggle="toc"></nav>
</div>
<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/js/dist/toc.min.js"></script>
{% endif %}
</div> <!-- #post-panel -->
+13
View 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
View File
@@ -0,0 +1 @@
$(function(){if($("#toc-wrap>nav#toc>ul>li").length==0){$("#toc-wrap>h3").addClass("hidden")}});