diff --git a/_layouts/post.html b/_layouts/post.html index 83e4230..7398f4e 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -100,12 +100,13 @@ layout: default {% if site.toc and page.toc %}

- {{ site.data.label.panel.toc }} + {{- site.data.label.panel.toc -}}

+ {% endif %} diff --git a/assets/js/_src/toc.js b/assets/js/_src/toc.js new file mode 100644 index 0000000..513e99a --- /dev/null +++ b/assets/js/_src/toc.js @@ -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"); + } +}); \ No newline at end of file diff --git a/assets/js/dist/toc.min.js b/assets/js/dist/toc.min.js new file mode 100644 index 0000000..c158e79 --- /dev/null +++ b/assets/js/dist/toc.min.js @@ -0,0 +1 @@ +$(function(){if($("#toc-wrap>nav#toc>ul>li").length==0){$("#toc-wrap>h3").addClass("hidden")}}); \ No newline at end of file