From e4ff96aee21354ccd51037df3be0a595e95c91c7 Mon Sep 17 00:00:00 2001 From: jtbx Date: Wed, 11 Oct 2023 21:55:42 +0200 Subject: [PATCH] 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. --- themes/ccchh/assets/sass/main.scss | 18 +++++++++++++++++ .../_default/_markup/render-image.html | 17 ++++++++++++++++ themes/ccchh/layouts/index.html | 4 ++-- themes/ccchh/layouts/partials/footer.html | 1 + themes/ccchh/layouts/shortcodes/clearfix.html | 1 + .../ccchh/layouts/shortcodes/img-resize.html | 20 +++++++++++++++++++ 6 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 themes/ccchh/layouts/_default/_markup/render-image.html create mode 100644 themes/ccchh/layouts/shortcodes/clearfix.html create mode 100644 themes/ccchh/layouts/shortcodes/img-resize.html diff --git a/themes/ccchh/assets/sass/main.scss b/themes/ccchh/assets/sass/main.scss index 6b53a0f..cefd070 100644 --- a/themes/ccchh/assets/sass/main.scss +++ b/themes/ccchh/assets/sass/main.scss @@ -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 #roomstate { diff --git a/themes/ccchh/layouts/_default/_markup/render-image.html b/themes/ccchh/layouts/_default/_markup/render-image.html new file mode 100644 index 0000000..65122df --- /dev/null +++ b/themes/ccchh/layouts/_default/_markup/render-image.html @@ -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 }} +

+ {{ $text }} +

+{{- end }} diff --git a/themes/ccchh/layouts/index.html b/themes/ccchh/layouts/index.html index 1af1d39..4c58c3e 100644 --- a/themes/ccchh/layouts/index.html +++ b/themes/ccchh/layouts/index.html @@ -8,7 +8,7 @@ {{- $upcoming := where $events ".Params.date" "ge" now }} {{ if $upcoming }}
-

Neuigkeiten

+

Neuigkeiten

{{- range $upcoming.ByDate }}
{{- partial "blog-header.html" (dict "headingLink" true "level" 4 "reduced" true "page" . ) }} @@ -26,7 +26,7 @@ {{- $home_sections := .Site.GetPage "/home" }} {{- range sort ($home_sections.Resources.Match "*.md") ".Name" }}
-

{{ .Title }}

+

{{ .Title }}

{{ .Content -}} {{- with .Params.Resources }} diff --git a/themes/ccchh/layouts/partials/footer.html b/themes/ccchh/layouts/partials/footer.html index 3e65991..a9019c8 100644 --- a/themes/ccchh/layouts/partials/footer.html +++ b/themes/ccchh/layouts/partials/footer.html @@ -1,4 +1,5 @@ +