Add shortcode to place resized images + fix md image for non-pagebundles

If a page is not a page bundle, it can't access files in the same
directory via the .Resources variable. So we need to detect this
condition and get the image file in another way.
This commit is contained in:
jtbx 2023-10-11 21:55:42 +02:00
parent f0a4d81451
commit e4ff96aee2
6 changed files with 59 additions and 2 deletions

View file

@ -78,6 +78,24 @@ body>main {
} }
} }
.float-left {
float: left;
margin-right: var(--grid-spacing-horizontal);
}
.float-right {
float: right;
margin-left: var(--grid-spacing-horizontal);
}
.clearfix {
&::after {
display: block;
clear: both;
content: "";
}
}
// Room State in Menu // Room State in Menu
#roomstate { #roomstate {

View file

@ -0,0 +1,17 @@
{{- $imagename := .Destination }}
{{- $text := .Text }}
{{- $title := .Title }}
{{- $isBundle := ne .Page.BundleType "" }}
{{- $page := .Page }}
{{- if not $isBundle }}
{{ $page_dir := path.Dir .Page.File }}
{{ $pagebundle_path := path.Join "/" $page_dir }}
{{ $page = .Page.Site.GetPage $pagebundle_path }}
{{- end -}}
{{- with $page.Resources.Get $imagename }}
<p class="md-img">
<img src="{{ .RelPermalink }}" alt="{{ $text }}" {{ with $title }} title="{{ . }}"{{ end }} />
</p>
{{- end }}

View file

@ -8,7 +8,7 @@
{{- $upcoming := where $events ".Params.date" "ge" now }} {{- $upcoming := where $events ".Params.date" "ge" now }}
{{ if $upcoming }} {{ if $upcoming }}
<div class="announcements"> <div class="announcements">
<h3>Neuigkeiten</h3> <h2>Neuigkeiten</h2>
{{- range $upcoming.ByDate }} {{- range $upcoming.ByDate }}
<div class="announcement"> <div class="announcement">
{{- partial "blog-header.html" (dict "headingLink" true "level" 4 "reduced" true "page" . ) }} {{- partial "blog-header.html" (dict "headingLink" true "level" 4 "reduced" true "page" . ) }}
@ -26,7 +26,7 @@
{{- $home_sections := .Site.GetPage "/home" }} {{- $home_sections := .Site.GetPage "/home" }}
{{- range sort ($home_sections.Resources.Match "*.md") ".Name" }} {{- range sort ($home_sections.Resources.Match "*.md") ".Name" }}
<div class="section"> <div class="section">
<h3>{{ .Title }}</h3> <h2>{{ .Title }}</h2>
{{ .Content -}} {{ .Content -}}
{{- with .Params.Resources }} {{- with .Params.Resources }}

View file

@ -1,4 +1,5 @@
<div class="clearfix"></div>
<footer class="container"> <footer class="container">
<nav class="menu"> <nav class="menu">
{{- partial "menu.html" (dict "menuID" "footer" "page" . ) -}} {{- partial "menu.html" (dict "menuID" "footer" "page" . ) -}}

View file

@ -0,0 +1 @@
<div class="clearfix"></div>

View file

@ -0,0 +1,20 @@
{{- $imagename := (.Get 0) }}
{{- $options := .Get 1 }}
{{- $classes := .Get 2 | default "" }}
{{- $link := .Get 3 | default "" }}
{{- $isBundle := ne .Page.BundleType "" }}
{{- $page := .Page }}
{{- if not $isBundle }}
{{ $page_dir := path.Dir .Page.File }}
{{ $pagebundle_path := path.Join "/" $page_dir }}
{{ $page = .Site.GetPage $pagebundle_path }}
{{- end -}}
{{- with $page.Resources.Get $imagename }}
{{- with .Resize $options -}}
{{ if $link }}<a href="{{ $link }}">{{ end }}
<img src="{{ .RelPermalink }}" class="md-img {{ $classes }}" width="{{ .Width }}" height="{{ .Height }}">
{{ if $link }}</a>{{ end }}
{{- end }}
{{- end }}