mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-12 20:15:25 +00:00
BREAKING CHANGE Module paths moved to `github.com/HugoBlox/kit` with new names: - core `blox-tailwind` → `blox` - analytics → `analytics` - netlify → `integrations/netlify` - slides (reveal) → `slides` Update go.mod, module.yaml/params, scripts, tests, and v0.11 migration guide accordingly.
42 lines
1.3 KiB
HTML
42 lines
1.3 KiB
HTML
{{/*
|
|
HugoBlox Image Engine: Get website logo
|
|
|
|
SVG-first detection for crisp rendering at any size.
|
|
Auto-detects from assets/media/:
|
|
1. logo.svg (preferred - vector, infinite scalability)
|
|
2. logo.png (fallback - raster, processed by Hugo)
|
|
|
|
Inputs:
|
|
- constraint: "max_height" or "fit" (default: "fit")
|
|
- size: int - Target size in pixels
|
|
|
|
Output: dict with:
|
|
- resource: The logo resource (processed if PNG)
|
|
- type: MIME type ("image/svg+xml" or "image/png")
|
|
- is_svg: boolean
|
|
*/}}
|
|
|
|
{{ $constraint := .constraint | default "fit" }}
|
|
{{ $size := .size | default 36 }}
|
|
{{ $result := dict "resource" nil "type" "" "is_svg" false }}
|
|
|
|
{{/* 1. Check for SVG first (preferred) */}}
|
|
{{ $logo_svg := resources.Get "media/logo.svg" }}
|
|
{{ if $logo_svg }}
|
|
{{ $result = dict "resource" $logo_svg "type" "image/svg+xml" "is_svg" true }}
|
|
{{ else }}
|
|
{{/* 2. Fallback to PNG */}}
|
|
{{ $logo_png := resources.Get "media/logo.png" }}
|
|
{{ if $logo_png }}
|
|
{{ $logo_processed := $logo_png }}
|
|
{{ if eq $constraint "max_height" }}
|
|
{{ $logo_processed = $logo_png.Resize (printf "x%d" $size) }}
|
|
{{ else }}
|
|
{{ $logo_processed = $logo_png.Fit (printf "%dx%d" $size $size) }}
|
|
{{ end }}
|
|
{{ $result = dict "resource" $logo_processed "type" "image/png" "is_svg" false }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
{{ return $result }}
|