feat: 自动隐藏文章目录/站点副标题为空时隐藏竖线 (#144)

* format code, hide post-toc when it's empty

* 当subtitle为空时去掉title后面的竖线
This commit is contained in:
Harukawa Sayaka
2022-02-09 10:19:33 +08:00
committed by GitHub
parent 04d503da50
commit ffbc4c07a0
2 changed files with 12 additions and 3 deletions
+6 -1
View File
@@ -8,8 +8,13 @@
{{ end }}
{{ if .IsHome -}}
{{ if .Site.Params.subtitle -}}
<title>{{ .Site.Title }} | {{ .Site.Params.subtitle}}</title>
<meta property="og:title" content="{{ .Site.Title }} | {{ .Site.Params.subtitle}}">
{{ else -}}
<title>{{ .Site.Title }}</title>
<meta property="og:title" content="{{ .Site.Title }}">
{{ end -}}
<meta property="og:type" content="website">
<meta name="Keywords" content="{{.Site.Params.keywords}}">
<meta name="description" content="{{ .Site.Params.description }}">
@@ -53,4 +58,4 @@
{{ range .Site.Params.customCSS }}
<link rel="stylesheet" href='{{ "/css/" | relURL }}{{ . }}'>
{{ end }}
</head>
</head>
+6 -2
View File
@@ -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();
}
})
</script>
{{- end }}