1
0
mirror of https://github.com/docker/docs.git synced 2026-10-23 18:09:02 +03:00
Files
docs/layouts/_partials/utils/description.html
2026-05-01 09:22:27 +02: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 `hugo.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 (hugo.Data.frontmatter) .Path) }}
{{ with .description }}
{{ $desc = strings.Replace . "\n" " " | strings.TrimRight " " }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ return $desc }}