Files
docker-docs/content/reference/cli/sbx/_content.gotmpl
T
2026-05-01 09:22:27 +02:00

49 lines
1.4 KiB
Go Template

{{- /*
Content adapter for sbx CLI reference pages.
Generates pages from YAML data files in hugo.Data.sbx_cli (cobra/doc format).
For each YAML file it creates a page at the command path (spaces → slashes).
Commands with child entries in see_also become Hugo sections; others become
regular pages.
*/ -}}
{{- range $name, $data := hugo.Data.sbx_cli -}}
{{- if not $data.name -}}
{{- continue -}}
{{- end -}}
{{- /* Determine if this command has child commands (from see_also) */ -}}
{{- $hasChildren := false -}}
{{- $prefix := printf "%s " $data.name -}}
{{- with $data.see_also -}}
{{- range . -}}
{{- $cmd := index (split . " - ") 0 -}}
{{- if strings.HasPrefix $cmd $prefix -}}
{{- $hasChildren = true -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- /* Compute path relative to this adapter (strip "sbx/" prefix) */ -}}
{{- $fullPath := replace $data.name " " "/" -}}
{{- $kind := cond $hasChildren "section" "page" -}}
{{- if eq $data.name "sbx" -}}
{{- /* Root command is the section index */ -}}
{{- $.AddPage (dict
"path" "."
"title" $data.name
"kind" "section"
"params" (dict "datafile" $name)
) -}}
{{- else -}}
{{- $relPath := strings.TrimPrefix "sbx/" $fullPath -}}
{{- $.AddPage (dict
"path" $relPath
"title" $data.name
"kind" $kind
"params" (dict "datafile" $name)
) -}}
{{- end -}}
{{- end -}}