Have page header only if needed

master
Will Faught 12 months ago
parent c9e87a6088
commit b1935e7720

@ -1,5 +1,6 @@
{{ $page := . }} {{ $page := . }}
{{ $alert := $page.Param "paige.alert" }}
{{ $authors := partial "paige/authors.html" $page }} {{ $authors := partial "paige/authors.html" $page }}
{{ $categories := $page.GetTerms "categories" }} {{ $categories := $page.GetTerms "categories" }}
{{ $date := and $page.IsPage $page.PublishDate }} {{ $date := and $page.IsPage $page.PublishDate }}
@ -8,80 +9,83 @@
{{ $link := $page.Params.link }} {{ $link := $page.Params.link }}
{{ $readingtime := $page.ReadingTime }} {{ $readingtime := $page.ReadingTime }}
{{ $series := $page.GetTerms "series" }} {{ $series := $page.GetTerms "series" }}
{{ $table := and $page.Content (ne $page.TableOfContents `<nav id="TableOfContents"></nav>`) }}
{{ $tags := $page.GetTerms "tags" }} {{ $tags := $page.GetTerms "tags" }}
{{ $textkeywords := eq ($page.Param "paige.keyword_style" | default "text") "text" }} {{ $textkeywords := eq ($page.Param "paige.keyword_style" | default "text") "text" }}
{{ $title := $page.Title | markdownify }} {{ $title := $page.Title | markdownify }}
{{ $keywords := sort (append $categories $tags) "Title" }} {{ $keywords := sort (append $categories $tags) "Title" }}
<header class="mw-100 align-items-center d-flex flex-column" id="paige-page-header"> {{ if or $authors $date $description $keywords $readingtime $series $table $title }}
{{ with $title }} <header class="mw-100 align-items-center d-flex flex-column" id="paige-page-header">
<h1 class="fw-bold text-center" id="paige-title">{{ if $link }}<a href="{{ $link }}">{{ . }}</a>{{ else }}{{ . }}{{ end }}</h1> {{ with $title }}
{{ end }} <h1 class="fw-bold text-center" id="paige-title">{{ if $link }}<a href="{{ $link }}">{{ . }}</a>{{ else }}{{ . }}{{ end }}</h1>
{{ end }}
{{ with $description }} {{ with $description }}
<p class="lead text-center" id="paige-description">{{ . }}</p> <p class="lead text-center" id="paige-description">{{ . }}</p>
{{ end }} {{ end }}
{{ if or $authors $date $keywords $readingtime $series }} {{ if or $authors $date $keywords $readingtime $series }}
<div class="my-3" id="paige-metadata-rest"> <div class="my-3" id="paige-metadata-rest">
{{ with $keywords }} {{ with $keywords }}
<p class="{{ if $textkeywords }} mb-0 {{ end }} text-center {{ if $textkeywords }} text-secondary {{ end }}" id="paige-keywords"> <p class="{{ if $textkeywords }} mb-0 {{ end }} text-center {{ if $textkeywords }} text-secondary {{ end }}" id="paige-keywords">
{{ range $i, $term := . -}} {{ range $i, $term := . -}}
{{- if $textkeywords -}} {{- if $textkeywords -}}
{{- if gt $i 0 }} · {{ end -}} {{- if gt $i 0 }} · {{ end -}}
<a class="link-secondary" href="{{ .RelPermalink | safeURL }}">{{ .Title }}</a> <a class="link-secondary" href="{{ .RelPermalink | safeURL }}">{{ .Title }}</a>
{{- else -}} {{- else -}}
{{- if gt $i 0 }} {{ end -}} {{- if gt $i 0 }} {{ end -}}
<a class="badge paige-keyword text-bg-secondary text-decoration-none" href="{{ .RelPermalink | safeURL }}">{{ .Title }}</a> <a class="badge paige-keyword text-bg-secondary text-decoration-none" href="{{ .RelPermalink | safeURL }}">{{ .Title }}</a>
{{- end -}} {{- end -}}
{{- end }} {{- end }}
</p> </p>
{{ end }} {{ end }}
{{ with $series }} {{ with $series }}
<p class="mb-0 text-center text-secondary" id="paige-series"> <p class="mb-0 text-center text-secondary" id="paige-series">
{{ range $i, $series := . -}} {{ range $i, $series := . -}}
{{- if gt $i 0 }} · {{ end -}} {{- if gt $i 0 }} · {{ end -}}
<a class="link-secondary" href="{{ .RelPermalink }}">{{ .Title }}</a> <a class="link-secondary" href="{{ .RelPermalink }}">{{ .Title }}</a>
{{- end }} {{- end }}
</p> </p>
{{ end }} {{ end }}
{{ with $authors }} {{ with $authors }}
<p class="mb-0 text-center text-secondary" id="paige-authors"> <p class="mb-0 text-center text-secondary" id="paige-authors">
{{ range $i, $author := . -}} {{ range $i, $author := . -}}
{{- if gt $i 0 }} · {{ end -}} {{- if gt $i 0 }} · {{ end -}}
<a class="link-secondary" href="{{ .RelPermalink }}">{{ .Title }}</a> <a class="link-secondary" href="{{ .RelPermalink }}">{{ .Title }}</a>
{{- end }} {{- end }}
</p> </p>
{{ end }} {{ end }}
{{ with $date }} {{ with $date }}
<p class="mb-0 text-center text-secondary" id="paige-date"> <p class="mb-0 text-center text-secondary" id="paige-date">
<time datetime="{{ .Format `2006-01-02` }}">{{ time.Format $dateformat . }}</time> <time datetime="{{ .Format `2006-01-02` }}">{{ time.Format $dateformat . }}</time>
</p> </p>
{{ end }} {{ end }}
{{ with $readingtime }} {{ with $readingtime }}
<p class="mb-0 text-center text-secondary" id="paige-reading-time">{{ . }} {{ i18n "paige_minutes" . }}</p> <p class="mb-0 text-center text-secondary" id="paige-reading-time">{{ . }} {{ i18n "paige_minutes" . }}</p>
{{ end }} {{ end }}
</div> </div>
{{ end }} {{ end }}
{{ with $page.Param "paige.alert" }} {{ with $alert }}
<div class="alert alert-{{ .type }} my-3" id="paige-alert" role="alert">{{ .message | markdownify }}</div> <div class="alert alert-{{ .type }} my-3" id="paige-alert" role="alert">{{ .message | markdownify }}</div>
{{ end }} {{ end }}
{{ if and $page.Content (ne $page.TableOfContents `<nav id="TableOfContents"></nav>`) }} {{ if $table }}
<div class="my-3" id="paige-toc"> <div class="my-3" id="paige-toc">
<div class="border mb-3 pe-3 ps-3 pt-3 rounded"> <div class="border mb-3 pe-3 ps-3 pt-3 rounded">
{{ $page.TableOfContents }} {{ $page.TableOfContents }}
</div>
</div> </div>
</div> {{ end }}
{{ end }} </header>
</header> {{ end }}

Loading…
Cancel
Save