hackertours/layouts/_partials/head/extra.html
Vincent Mahnke 75a8d446e4
All checks were successful
/ build (push) Successful in 1m14s
/ accessibility (push) Successful in 2m2s
Keeps logo size across languages and resolves mobile menu overlap (#68)
## Header

![image](/attachments/dd741d30-ffbe-49ad-b717-cd3e7bd46bcb)

## Mobile menu
| | |
| --- | --- |
| ![localhost_8888_en_ (1)](/attachments/ce78aa3d-b229-457a-add5-0d5e3ddc71ec) | ![localhost_8888_en_](/attachments/ae1832d5-605d-4bd5-b41a-b7fe9d6e14e5) |

Reviewed-on: #68
2026-11-07 21:28:53 +01:00

51 lines
2.1 KiB
HTML

{{- /*
Open Graph image for link previews. The theme's head/meta.html writes og:image only for the
"image" param; without it, this uses the first image in the page, a Markdown image or a
gallery-image shortcode, scaled down to at most 1200 pixels wide, with its alt text as
og:image:alt.
*/ -}}
{{- if not ($.Param "image") -}}
{{- /* Whichever comes first: a Markdown image or a gallery-image shortcode (src and alt in "…" or `…`). */ -}}
{{- with findRESubmatch `!\[([^\]]*)\]\(\s*<?([^\s)>]+)|\{\{<\s*gallery-image\s([^}]*)>\}\}` .RawContent 1 -}}
{{- $alt := index . 0 1 -}}
{{- $dest := index . 0 2 -}}
{{- with index . 0 3 -}}
{{- $dest = "" -}}
{{- $alt = "" -}}
{{- with findRESubmatch "\\bsrc=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $dest = or (index . 0 1) (index . 0 2) }}{{ end -}}
{{- with findRESubmatch "\\balt=(?:\"([^\"]*)\"|`([^`]*)`)" . 1 }}{{ $alt = or (index . 0 1) (index . 0 2) }}{{ end -}}
{{- end -}}
{{- $url := "" -}}
{{- $width := 0 -}}
{{- $height := 0 -}}
{{- $resource := false -}}
{{- if findRE `^https?://` $dest -}}
{{- $url = $dest -}}
{{- else -}}
{{- $resource = or ($.Resources.Get (strings.TrimPrefix "./" $dest)) (resources.Get $dest) -}}
{{- end -}}
{{- with $resource -}}
{{- $image := . -}}
{{- if and (eq .ResourceType "image") (ne .MediaType.SubType "svg") -}}
{{- /* Turned as its EXIF orientation says; Hugo doesn't do that when it resizes. */ -}}
{{- $image = .Filter images.AutoOrient -}}
{{- if gt $image.Width 1200 }}{{ $image = $image.Resize "1200x" }}{{ end -}}
{{- $width = $image.Width -}}
{{- $height = $image.Height -}}
{{- end -}}
{{- $url = $image.Permalink -}}
{{- end -}}
{{- with $url }}
<meta property="og:image" content="{{ . }}">
{{- with $width }}
<meta property="og:image:width" content="{{ . }}">
<meta property="og:image:height" content="{{ $height }}">
{{- end }}
{{- with $alt }}
<meta property="og:image:alt" content="{{ . }}">
{{- end }}
<meta name="twitter:card" content="summary_large_image">
{{- end -}}
{{- end -}}
{{- end -}}