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 public
resources resources
themes themes
assets/img
static/img static/img
.hugo_build.lock .hugo_build.lock

View file

@ -18,10 +18,10 @@
{{- if $refPage -}} {{- if $refPage -}}
<a href="{{ $refPage.Permalink }}"><img <a href="{{ $refPage.Permalink }}"><img
width="100%" class="mt-3" width="100%" class="mt-3"
src="{{ $image.RelPermalink }}" alt="{{ .Params.title }}"></a> src="{{ $image.RelPermalink }}" alt="{{ $refPage.Title }}"></a>
{{- else -}} {{- else -}}
<img width="100%" class="mt-3" <img width="100%" class="mt-3"
src="{{ $image.RelPermalink }}" alt="{{ .Params.title }}"> src="{{ $image.RelPermalink }}" alt="{{ .Title }}">
{{- end -}} {{- end -}}
{{- else if .Params.teaser -}} {{- else if .Params.teaser -}}
<div class="card mt-3"> <div class="card mt-3">
@ -57,46 +57,46 @@
</div> </div>
{{- end }} {{- end }}
{{ if not .Site.Params.hideParentArticles -}} {{- if not .Site.Params.hideParentArticles -}}
{{- $related := where .Site.RegularPages "Params.pageid" "in" .Params.parents -}} {{- $related := where .Site.RegularPages "Params.pageid" "in" .Params.parents -}}
{{- partial "card-related" {{- partial "card-related"
(dict "related" $related "header" (i18n "parent-articles") "id" "parents") -}} (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") -}} (ne .Site.Params.showChildArticles "sidebar") -}}
{{- $related := .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}} {{- $related := .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}}
{{- partial "card-related" {{- partial "card-related"
(dict "related" $related "header" (i18n "child-articles") "id" "children") -}} (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" -}} {{- $related := .Site.RegularPages.RelatedIndices . "topics" -}}
{{- partial "card-related" {{- partial "card-related"
(dict "related" $related "header" (i18n "related-articles") "id" "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" -}} {{- $related := .Site.RegularPages.RelatedIndices . "parents" -}}
{{- partial "card-related" {{- partial "card-related"
(dict "related" $related "header" (i18n "sibling-articles") "id" "siblings") -}} (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" -}} {{- $section := or .Section "posts" -}}
{{- $header := or (i18n (printf "articles-in-%s" $section)) (i18n "articles-in-section") -}} {{- $header := or (i18n (printf "articles-in-%s" $section)) (i18n "articles-in-section") -}}
{{- $related := first 20 (where .Site.RegularPages "Section" $section) -}} {{- $related := first 20 (where .Site.RegularPages "Section" $section) -}}
{{- partial "card-related" {{- partial "card-related"
(dict "related" $related "header" $header "id" "articles-in-section") -}} (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" -}} {{- $related := .Scratch.Get "backlinks" -}}
{{- partial "card-related" {{- partial "card-related"
(dict "related" $related "header" (i18n "backlinks") "id" "backlinks") -}} (dict "related" $related "header" (i18n "backlinks") "id" "backlinks") -}}
{{- end }} {{- end -}}
{{ if .Params.showtoc -}} {{- if .Params.showtoc -}}
<div class="card mt-3"> <div class="card mt-3">
<div class="card-header"> <div class="card-header">
<h4 class="card-text">{{i18n "toc"}}</h4> <h4 class="card-text">{{i18n "toc"}}</h4>
@ -105,6 +105,6 @@
{{ .TableOfContents }} {{ .TableOfContents }}
</div> </div>
</div> </div>
{{ end -}} {{- end -}}
</div> </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") -}} {{- $pid := or (.Get "pid") (.Get "page") -}}
{{- $pages := where .Site.RegularPages "Params.pageid" "eq" $pid -}}
{{- $frag := or (.Get "id") (.Get "anchor") -}} {{- $frag := or (.Get "id") (.Get "anchor") -}}
{{- $this := $.Page -}}
{{- $pages := where .Site.RegularPages "Params.pageid" "eq" $pid -}}
{{- $fragsep := cond (eq $frag "") "" "#" -}} {{- $fragsep := cond (eq $frag "") "" "#" -}}
{{- $inner := .Inner -}} {{- $inner := .Inner -}}
{{- range $pages -}} {{- range $pages -}}