diff options
author | zilcH40 <wlh233@live.com> | 2022-09-12 19:05:31 +0300 |
---|---|---|
committer | zilcH40 <wlh233@live.com> | 2022-09-12 19:05:31 +0300 |
commit | c6535284e9a632d58670f26a4e7689c73e868a8c (patch) | |
tree | 8b09eb84025f70227d199603ca2a1b766c502060 | |
parent | 2d91340c2ba695f935e101e7ab98347c2c72747f (diff) |
update logic of toc and date format in archives page
-rw-r--r-- | layouts/_default/single.html | 2 | ||||
-rw-r--r-- | layouts/archives/single.html | 2 | ||||
-rw-r--r-- | layouts/partials/post.html | 10 |
3 files changed, 9 insertions, 5 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 048b788..8ead5f0 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -11,7 +11,7 @@ {{- partial "math.html" . -}} {{ end }} - {{ if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) }} + {{ if or .Params.toc .Site.Params.toc }} {{- partial "toc.html" . -}} {{ end }} {{ end }} diff --git a/layouts/archives/single.html b/layouts/archives/single.html index 728e628..cd7f947 100644 --- a/layouts/archives/single.html +++ b/layouts/archives/single.html @@ -15,7 +15,7 @@ <ul class="listing"> {{ range .Pages }} <li> - <span class="date">{{ .Date.Format "2006/01/02" }} </span> + <span class="is-family-monospace">{{ .Date.Format "2006/01/02" }} </span> <a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title }}</a> </li> {{ end }} diff --git a/layouts/partials/post.html b/layouts/partials/post.html index 5a8c2e6..0d27aee 100644 --- a/layouts/partials/post.html +++ b/layouts/partials/post.html @@ -1,8 +1,12 @@ {{ partial "post-header.html" . }} +{{- $setToc := or .Params.toc .Site.Params.toc -}} +{{- $headers := findRE "<h[1-3].*?>(.|\n])+?</h[1-3]>" .Content -}} +{{- $hasToc := ge (len $headers) 1 -}} +{{- $showToc := and $setToc $hasToc -}} <section class="section"> <div class="container"> <div class="columns"> - {{ if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) }} + {{ if $showToc }} <div class="column is-1 is-hidden-mobile"></div> <div class="column is-8"> {{ else }} @@ -12,10 +16,10 @@ {{- .Content -}} </article> </div> - {{ if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) }} + {{ if $showToc }} <div class="column is-hidden-mobile"> <div class="sidebar" id="toc"> - {{ if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) }} + {{ if $showToc }} <div class="post post-toc" id="post-toc"> <!-- render by tocbot --> </div> |