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:
parent
f0a4d81451
commit
e4ff96aee2
|
@ -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 {
|
||||||
|
|
17
themes/ccchh/layouts/_default/_markup/render-image.html
Normal file
17
themes/ccchh/layouts/_default/_markup/render-image.html
Normal 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 }}
|
|
@ -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 }}
|
||||||
|
|
|
@ -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" . ) -}}
|
||||||
|
|
1
themes/ccchh/layouts/shortcodes/clearfix.html
Normal file
1
themes/ccchh/layouts/shortcodes/clearfix.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<div class="clearfix"></div>
|
20
themes/ccchh/layouts/shortcodes/img-resize.html
Normal file
20
themes/ccchh/layouts/shortcodes/img-resize.html
Normal 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 }}
|
Loading…
Reference in a new issue