From ffbc4c07a01cbd01c3d3ea4c821eeffd9530a221 Mon Sep 17 00:00:00 2001 From: Harukawa Sayaka Date: Wed, 9 Feb 2022 10:19:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=8A=A8=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E7=9B=AE=E5=BD=95/=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E5=89=AF=E6=A0=87=E9=A2=98=E4=B8=BA=E7=A9=BA=E6=97=B6=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E7=AB=96=E7=BA=BF=20(#144)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * format code, hide post-toc when it's empty * 当subtitle为空时去掉title后面的竖线 --- layouts/partials/head.html | 7 ++++++- layouts/partials/toc.html | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/layouts/partials/head.html b/layouts/partials/head.html index a70e29f..e8fde85 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -8,8 +8,13 @@ {{ end }} {{ if .IsHome -}} + {{ if .Site.Params.subtitle -}} {{ .Site.Title }} | {{ .Site.Params.subtitle}} + {{ else -}} + {{ .Site.Title }} + + {{ end -}} @@ -53,4 +58,4 @@ {{ range .Site.Params.customCSS }} {{ end }} - + \ No newline at end of file diff --git a/layouts/partials/toc.html b/layouts/partials/toc.html index 39617b2..bdefff8 100644 --- a/layouts/partials/toc.html +++ b/layouts/partials/toc.html @@ -71,8 +71,8 @@ var postToc = $(".post-toc"); if (postToc.length) { var leftPos = $("#main").offset().left; - if(leftPos<220){ - postToc.css({"width":leftPos-10,"margin-left":(0-leftPos)}) + if (leftPos < 220) { + postToc.css({ "width": leftPos - 10, "margin-left": (0 - leftPos) }) } var t = postToc.offset().top - 20, @@ -91,6 +91,10 @@ e < t ? postToc.css(a.start) : postToc.css(a.process) }) } + + if ($("#TableOfContents").children().length < 1) { + $(".post-toc").remove(); + } }) {{- end }} \ No newline at end of file