AMPERION_Webpage/layouts/partials/logo.html

63 lines
2.8 KiB
HTML
Raw Normal View History

2025-07-24 00:03:22 +02:00
{{ $logoPath := site.Params.logo }}
{{ $logoHoverPath := site.Params.logo_hover }} <!-- Neuer Parameter für das Hover-Logo -->
{{ $logoWidth := replace site.Params.logo_width "px" "x" }}
2025-06-06 18:12:46 +02:00
2025-07-24 00:03:22 +02:00
<!-- Überprüfen, ob das Logo existiert -->
2025-06-06 18:12:46 +02:00
{{ if $logoPath }}
2025-07-24 00:03:22 +02:00
{{ if fileExists (add `assets/` $logoPath) }}
{{ $logo := resources.Get $logoPath }}
{{ $logoExt := path.Ext $logo }}
2025-06-06 18:12:46 +02:00
2025-07-24 00:03:22 +02:00
<!-- Logo-Höhe und -Breite (wenn nicht SVG) -->
{{ if eq $logoExt `.svg` }}
{{ .Scratch.Set "logo-width" "" }}
{{ .Scratch.Set "logo-height" "" }}
{{ else }}
{{ .Scratch.Set "logo-width" $logo.Width }}
{{ .Scratch.Set "logo-height" $logo.Height }}
{{ end }}
2025-06-06 18:12:46 +02:00
2025-07-24 00:03:22 +02:00
{{ $logoDefaultWidth := .Scratch.Get "logo-width" }}
{{ $logoDefaultHeight := .Scratch.Get "logo-height" }}
2025-06-06 18:12:46 +02:00
2025-07-24 00:03:22 +02:00
<!-- Überprüfen, ob das Logo ein GIF ist -->
{{ if eq $logoExt ".gif" }}
{{ .Scratch.Set "logo" ($logo.Resize $logoWidth).RelPermalink }}
{{ else if eq $logoExt ".svg" }}
{{ .Scratch.Set "logo" $logo.RelPermalink }}
{{ else }}
{{ $logoDefaultWidth := add (string $logoDefaultWidth) "x" }}
{{ $logoWidth := $logoWidth | default $logoDefaultWidth }}
{{ $options := add (string $logoWidth) " webp" }}
{{ .Scratch.Set "logo" ($logo.Resize $options).RelPermalink }}
{{ .Scratch.Set "logo_fallback" ($logo.Resize $logoWidth).RelPermalink }}
{{ end }}
2025-06-06 18:12:46 +02:00
2025-07-24 00:03:22 +02:00
<!-- Hover-Logo laden -->
{{ if $logoHoverPath }}
{{ if fileExists (add `assets/` $logoHoverPath) }}
{{ $logoHover := resources.Get $logoHoverPath }}
{{ $logoHoverExt := path.Ext $logoHover }}
{{ if eq $logoHoverExt ".gif" }}
{{ .Scratch.Set "logo_hover" ($logoHover.Resize $logoWidth).RelPermalink }}
{{ else if eq $logoHoverExt ".svg" }}
{{ .Scratch.Set "logo_hover" $logoHover.RelPermalink }}
{{ else }}
{{ $optionsHover := add (string $logoWidth) " webp" }}
{{ .Scratch.Set "logo_hover" ($logoHover.Resize $optionsHover).RelPermalink }}
{{ .Scratch.Set "logo_hover_fallback" ($logoHover.Resize $logoWidth).RelPermalink }}
{{ end }}
{{ end }}
{{ end }}
<!-- Logo anzeigen -->
<img loading="preload" decoding="async" class="img-fluid logo-up" width="{{ replace $logoWidth `x` `` | default $logoDefaultWidth }}" height="{{ $logoDefaultHeight }}" src="{{ .Scratch.Get `logo` }}" alt="{{ site.Title }}" onerror="this.onerror=null;this.src='{{ .Scratch.Get `logo_fallback` }}'" onmouseover="this.src='{{ .Scratch.Get `logo_hover` }}'" onmouseout="this.src='{{ .Scratch.Get `logo` }}'">
{{ else }}
<strong class="text-danger">`{{ $logoPath }}` doesn't exist</strong>
{{ end }}
2025-06-06 18:12:46 +02:00
{{ else if site.Params.logo_text }}
2025-07-24 00:03:22 +02:00
{{ site.Params.logo_text | markdownify }}
2025-06-06 18:12:46 +02:00
{{ else }}
2025-07-24 00:03:22 +02:00
{{ site.Title | markdownify }}
{{ end }}