mirror of
https://github.com/docker/docs.git
synced 2026-06-19 07:35:16 +00:00
122761ce2f
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
49 lines
1.4 KiB
Go Template
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 -}}
|