hugo-theme-cybercards/layouts/partials/sidebar.html

128 lines
4 KiB
HTML

<div class="col-md-4 mt20" id="cs-sidebar">
{{- $refImg := "" -}}
{{- $refPage := "" -}}
{{- $img := .Params.img -}}
{{- if .Params.imgref -}}
{{- range where .Site.RegularPages "Params.pageid" "eq" .Params.imgref -}}
{{- $refImg = .Params.img -}}
{{- $refPage = . -}}
{{- end -}}
{{- end -}}
{{- if not $img -}}
{{- $img = $refImg -}}
{{- end -}}
{{ if $img -}}
{{- $image := (resources.Get (printf "img/%s" $img)).Resize "400x" -}}
{{- if $refPage -}}
<a href="{{ $refPage.Permalink }}"><img
width="100%" class="mt-3"
src="{{ $image.RelPermalink }}"
alt="{{ $refPage.Title }}"
title="{{ $refPage.Title }}"></a>
{{- else -}}
<img width="100%" class="mt-3"
src="{{ $image.RelPermalink }}"
alt="{{ .Title }}"
{{- if .Params.imgtitle -}}
title="{{ .Params.imgtitle }}"
{{- end -}}>
{{- end -}}
{{- else if .Params.PageTeaser -}}
<div class="card mt-3">
<div class="card-body">
<h5 class="card-text">{{ .Params.PageTeaser }}</h5>
</div>
</div>
{{- else if .Params.teaser -}}
<div class="card mt-3">
<div class="card-body">
<h5 class="card-text">{{ .Params.Teaser }}</h5>
</div>
</div>
{{- else if .Site.Params.DefaultImage -}}
<img width="100%" class="mt-3"
src="{{ .Site.BaseURL }}img/{{ .Site.Params.defaultImage }}"
alt="Default Dmage">
{{- else if .Params.Summary -}}
<div class="card mt-3">
<div class="card-body">
<h5 class="card-text">{{ .Summary }}</h5>
</div>
</div>
{{- end }}
{{ with .Params.Topics -}}
<div class="card mt-3">
<div class="card-header">
<h4 class="card-text">{{i18n "topics"}}</h4>
</div>
<div class="card-body">
{{ range . -}}
{{- $page := $.GetPage (printf "/topics/%s" .) -}}
<span class="badge rounded-pill bg-secondary m-1">
<a href="{{ $page.Permalink }}">{{ $page.Title }}</a>
</span>
{{- end }}
</div>
</div>
{{- end }}
{{- if not .Site.Params.hideParentArticles -}}
{{- $related := where .Site.Pages "Params.pageid" "in" .Params.parents -}}
{{- partial "card-related"
(dict "related" $related "header" (i18n "parent-articles") "id" "parents") -}}
{{- end -}}
{{- if and (not .Site.Params.hideChildArticles)
(ne .Site.Params.showChildArticles "cards") -}}
{{- $related := .Site.Pages.RelatedTo (keyVals "parents" .Params.pageid) -}}
{{- partial "card-related"
(dict "related" $related.ByWeight
"header" (i18n "child-articles") "id" "children") -}}
{{- end -}}
{{- if not .Site.Params.hideRelatedArticles -}}
{{- $related := .Site.RegularPages.RelatedIndices . "topics" -}}
{{- partial "card-related"
(dict "related" $related.ByWeight
"header" (i18n "related-articles") "id" "related") -}}
{{- end -}}
{{- if not .Site.Params.hideSiblingArticles -}}
{{- $related := .Site.Pages.RelatedIndices . "parents" -}}
{{- partial "card-related"
(dict "related" $related.ByWeight
"header" (i18n "sibling-articles") "id" "siblings") -}}
{{- end -}}
{{- 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 -}}
{{- if not .Site.Params.hideBacklinks -}}
{{- $related := .Scratch.Get "backlinks" -}}
{{- partial "card-related"
(dict "related" $related "header" (i18n "backlinks") "id" "backlinks") -}}
{{- end -}}
{{- if .Params.showtoc -}}
<div class="card mt-3">
<div class="card-header">
<h4 class="card-text">{{i18n "toc"}}</h4>
</div>
<div class="card-body">
{{ .TableOfContents }}
</div>
</div>
{{- end -}}
<div class="mt-3">
</div>
</div>