add iimg short code; + minor layout improvements

This commit is contained in:
Helmut Merz 2022-01-29 09:36:25 +01:00
parent f3d9139033
commit 9930b31d67
4 changed files with 46 additions and 18 deletions

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
public
resources
themes
assets/img
static/img
.hugo_build.lock

View file

@ -18,10 +18,10 @@
{{- if $refPage -}}
<a href="{{ $refPage.Permalink }}"><img
width="100%" class="mt-3"
src="{{ $image.RelPermalink }}" alt="{{ .Params.title }}"></a>
src="{{ $image.RelPermalink }}" alt="{{ $refPage.Title }}"></a>
{{- else -}}
<img width="100%" class="mt-3"
src="{{ $image.RelPermalink }}" alt="{{ .Params.title }}">
src="{{ $image.RelPermalink }}" alt="{{ .Title }}">
{{- end -}}
{{- else if .Params.teaser -}}
<div class="card mt-3">
@ -57,46 +57,46 @@
</div>
{{- end }}
{{ if not .Site.Params.hideParentArticles -}}
{{- if not .Site.Params.hideParentArticles -}}
{{- $related := where .Site.RegularPages "Params.pageid" "in" .Params.parents -}}
{{- partial "card-related"
(dict "related" $related "header" (i18n "parent-articles") "id" "parents") -}}
{{- end }}
{{- end -}}
{{ if and (not .Site.Params.hideChildArticles)
{{- if and (not .Site.Params.hideChildArticles)
(ne .Site.Params.showChildArticles "sidebar") -}}
{{- $related := .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}}
{{- partial "card-related"
(dict "related" $related "header" (i18n "child-articles") "id" "children") -}}
{{- end }}
{{- end -}}
{{ if not .Site.Params.hideRelatedArticles -}}
{{- if not .Site.Params.hideRelatedArticles -}}
{{- $related := .Site.RegularPages.RelatedIndices . "topics" -}}
{{- partial "card-related"
(dict "related" $related "header" (i18n "related-articles") "id" "related") -}}
{{- end }}
{{- end -}}
{{ if not .Site.Params.hideSiblingArticles -}}
{{- if not .Site.Params.hideSiblingArticles -}}
{{- $related := .Site.RegularPages.RelatedIndices . "parents" -}}
{{- partial "card-related"
(dict "related" $related "header" (i18n "sibling-articles") "id" "siblings") -}}
{{- end }}
{{- end -}}
{{ if not .Site.Params.hideSectionArticles -}}
{{- if not .Site.Params.hideSectionArticles -}}
{{- $section := or .Section "posts" -}}
{{- $header := or (i18n (printf "articles-in-%s" $section)) (i18n "articles-in-section") -}}
{{- $related := first 20 (where .Site.RegularPages "Section" $section) -}}
{{- partial "card-related"
(dict "related" $related "header" $header "id" "articles-in-section") -}}
{{- end }}
{{- end -}}
{{ if not .Site.Params.hideBacklinks -}}
{{- if not .Site.Params.hideBacklinks -}}
{{- $related := .Scratch.Get "backlinks" -}}
{{- partial "card-related"
(dict "related" $related "header" (i18n "backlinks") "id" "backlinks") -}}
{{- end }}
{{- end -}}
{{ if .Params.showtoc -}}
{{- if .Params.showtoc -}}
<div class="card mt-3">
<div class="card-header">
<h4 class="card-text">{{i18n "toc"}}</h4>
@ -105,6 +105,6 @@
{{ .TableOfContents }}
</div>
</div>
{{ end -}}
{{- end -}}
</div>

View file

@ -0,0 +1,27 @@
<p>
{{- $img := or (.Get "src") (.Get "img") -}}
{{- $ref := .Get "ref" -}}
{{- $scale := .Get "scale" -}}
{{- $alt := or (.Get "alt") (.Get "title") -}}
{{- $refImg := "" -}}
{{- $refPage := "" -}}
{{- if $ref -}}
{{- range where .Site.RegularPages "Params.pageid" "eq" $ref -}}
{{- $refImg = .Params.img -}}
{{- $refPage = . -}}
{{- end -}}
{{- end -}}
{{- if not $img -}}
{{- $img = $refImg -}}
{{- end -}}
{{- $image := (resources.Get (printf "img/%s" $img)) -}}
{{- if $scale -}}
{{- $image = $image.Resize $scale -}}
{{- end -}}
{{- if $refPage -}}
<a href="{{ $refPage.Permalink }}"><img
src="{{ $image.RelPermalink }}" alt="{{ or $alt $refPage.Title }}"></a>
{{- else -}}
<img src="{{ $image.RelPermalink }}" alt="{{ $alt }}">
{{- end -}}
</p>

View file

@ -1,7 +1,7 @@
{{- $this := $.Page -}}
{{- $pid := or (.Get "pid") (.Get "page") -}}
{{- $pages := where .Site.RegularPages "Params.pageid" "eq" $pid -}}
{{- $frag := or (.Get "id") (.Get "anchor") -}}
{{- $this := $.Page -}}
{{- $pages := where .Site.RegularPages "Params.pageid" "eq" $pid -}}
{{- $fragsep := cond (eq $frag "") "" "#" -}}
{{- $inner := .Inner -}}
{{- range $pages -}}