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

View File

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

View File

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

View File

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

View File

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