Files
docker-docs/layouts/partials/utils/description.html
2025-01-20 10:30:58 +01:00

20 lines
674 B
HTML

{{- /*
Utility template to extract a description for the current page.
- Prioritizes `.Description` or falls back to front matter in `site.Data.frontmatter`.
- Replaces newlines with spaces and trims trailing spaces.
- Designed for reuse via `partial` calls to generate meta descriptions or similar content.
*/ -}}
{{ $desc := "" }}
{{ if .Description }}
{{ $desc = strings.Replace .Description "\n" " " }}
{{ else }}
{{ with .File }}
{{ with (index (site.Data.frontmatter) .Path) }}
{{ with .description }}
{{ $desc = strings.Replace . "\n" " " | strings.TrimRight " " }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ return $desc }}