Refactor some templating to avoid spurious whitespace
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-08-13 01:53:36 +02:00
parent d8c36e5077
commit 1e5e965572
5 changed files with 47 additions and 51 deletions

View File

@ -1,24 +1,23 @@
{{ define "main" }} {{- define "main" }}
<main> <main>
<article> <article>
{{ if in site.Params.mainSections .Page.Section }} {{- if in site.Params.mainSections .Page.Section }}
<h1 class="page-title blog">{{ .Title }}</h1> <h1 class="page-title blog">{{ .Title }}</h1>
{{ else }} {{- else }}
<h1 class="page-title">{{ .Title }}</h1> <h1 class="page-title">{{ .Title }}</h1>
{{ end }} {{- end }}
{{- /* Show post information if it's a post, otherwise just the content */ -}} {{- /* Show post information if it's a post, otherwise just the content */ -}}
{{ if in site.Params.mainSections .Page.Section }} {{- if in site.Params.mainSections .Page.Section }}
<p class="blog-post-info">Posted: <time>{{ .Date.Format "2006-01-02" }}</time> <p class="blog-post-info">Posted: <time>{{- .Date.Format "2006-01-02" -}}</time>
{{ partial "blog-taxonomy-info" . }}</p> {{- partial "blog-taxonomy-info" . }}
</p>
<div class="blog-post-content"> <div class="blog-post-content">
{{ .Content }} {{ .Content }}
</div> </div>
{{ template "_internal/disqus.html" . }} {{- template "_internal/disqus.html" . }}
{{ else }} {{- else }}
{{ .Content }} {{- .Content }}
{{ end }} {{- end }}
</article> </article>
</main> </main>
{{ end }} {{- end }}

View File

@ -38,5 +38,4 @@
{{ end }} {{ end }}
</main> </main>
&nbsp;<br />
{{ end }} {{ end }}

View File

@ -1,17 +1,16 @@
{{ with .Params.Categories }} {{- with .Params.Categories }}
<span class="blog-taxonomy-info"> &nbsp; | &nbsp; Categories: <span class="blog-taxonomy-info"> &nbsp; | &nbsp; Categories:
{{ $sort := sort . }} {{- $sort := sort . }}
{{ $links := apply $sort "partial" "post-category-link" "." }} {{- $links := apply $sort "partial" "post-category-link" "." }}
{{ $clean := apply $links "chomp" "." }} {{- $clean := apply $links "chomp" "." }}
{{ delimit $clean ", " | safeHTML }} {{- delimit $clean ", " | safeHTML }}
</span> </span>
{{ end }} {{- end }}
{{- with .Params.Tags }}
{{ with .Params.Tags }}
<span class="blog-taxonomy-info"> &nbsp; | &nbsp; Tags: <span class="blog-taxonomy-info"> &nbsp; | &nbsp; Tags:
{{ $sort := sort . }} {{- $sort := sort . }}
{{ $links := apply $sort "partial" "post-tag-link" "." }} {{- $links := apply $sort "partial" "post-tag-link" "." }}
{{ $clean := apply $links "chomp" "." }} {{- $clean := apply $links "chomp" "." }}
{{ delimit $clean ", " | safeHTML }} {{- delimit $clean ", " | safeHTML }}
</span> </span>
{{ end }} {{- end -}}

View File

@ -1,18 +1,19 @@
<footer class='page-footer'> <footer class='page-footer'>
{{ $socialMap := .Site.Data.notrack.social }} {{- $socialMap := .Site.Data.notrack.social }}
{{ with $.Site.Params.social }} {{- with $.Site.Params.social }}
<div class="social"> <div class="social">
<ul> <ul>
{{- $socialArray := slice -}} {{- $socialArray := slice -}}
{{ range $website, $user := $.Site.Params.social }} {{- range $website, $user := $.Site.Params.social }}
{{- $social := $website | lower | index $socialMap | default dict -}} {{- $social := $website | lower | index $socialMap | default dict -}}
{{- $social := dict "user" $user | merge $social -}} {{- $social := dict "user" $user | merge $social -}}
{{- $data := index $socialMap $website -}} {{- $data := index $socialMap $website -}}
{{- $socialArray = $socialArray | append $social -}} {{- $socialArray = $socialArray | append $social -}}
{{ end }} {{- end }}
{{ range sort $socialArray "weight" -}} {{- range sort $socialArray "weight" -}}
{{- if .prefix -}} {{- if .prefix -}}
<li><a href="{{- .prefix -}}{{ .user }}" rel="me"><i class="{{- .icon.class -}}"></i>{{ .title }}</a></li> <li><a href="{{- .prefix -}}{{ .user }}" rel="me"><i class="{{- .icon.class -}}"></i>{{ .title }}</a></li>
{{- else if .template -}} {{- else if .template -}}
@ -23,6 +24,6 @@
{{- end -}} {{- end -}}
</ul> </ul>
</div> </div>
{{ end }} {{- end }}
{{ printf " <!-- Icons are from Awesome Font, licensed under SIL OFL 1.1 (https://scripts.sil.org/OFL) -->" | safeHTML }} {{ printf " <!-- Icons are from Awesome Font, licensed under SIL OFL 1.1 (https://scripts.sil.org/OFL) -->" | safeHTML }}
</footer> </footer>

View File

@ -1,20 +1,18 @@
<figure class="image-shortcode{{ with .Get "class" }} {{ . }}{{ end }} <figure class="image-shortcode{{ with .Get "class" }} {{ . }}{{ end }}
{{- with .Get "wide" }}{{- if eq . "true" }} wide{{ end -}}{{ end -}} {{- with .Get "wide" }}{{- if eq . "true" }} wide{{ end -}}{{ end -}}
{{- with .Get "frame" }}{{- if eq . "true" }} frame{{ end -}}{{ end -}} {{- with .Get "frame" }}{{- if eq . "true" }} frame{{ end -}}{{ end -}}
{{- with .Get "float" }} {{ . }}{{ end -}}" {{- with .Get "float" }} {{ . }}{{ end -}}" style="
style="
{{- with .Get "width" }}width: {{ . }};{{ end -}} {{- with .Get "width" }}width: {{ . }};{{ end -}}
{{- with .Get "height" }}height: {{ . }};{{ end -}}"> {{- with .Get "height" }}height: {{ . }};{{ end -}}">
{{- if .Get "link" -}} {{- if .Get "link" -}}
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}> <a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
{{- end }} {{- end }}
<img src="{{ .Get "src" | relURL }}" <img src="{{ .Get "src" | relURL }}"
{{- if or (.Get "alt") (.Get "caption") }} {{- if or (.Get "alt") (.Get "caption") }} alt="{{ with .Get "alt" }}{{ replace . "'" "&#39;" }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
alt="{{ with .Get "alt" }}{{ replace . "'" "&#39;" }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
{{- end -}} {{- end -}}
/> <!-- Closing img tag --> /> <!-- Closing img tag -->
{{- if .Get "link" }}</a>{{ end -}} {{- if .Get "link" }}</a>{{ end -}}
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}} {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") }}
<figcaption> <figcaption>
{{ with (.Get "title") -}} {{ with (.Get "title") -}}
<h4>{{ . }}</h4> <h4>{{ . }}</h4>