Skip to content

Commit ecc54f2

Browse files
committed
hugo: align cli table styles with defaults, add horizontal overflow
Signed-off-by: David Karlsson <[email protected]>
1 parent ffd3ccd commit ecc54f2

File tree

1 file changed

+90
-86
lines changed

1 file changed

+90
-86
lines changed

layouts/_default/cli.html

Lines changed: 90 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,40 @@
1111
<article class="prose min-w-0 flex-[2_2_0%] max-w-4xl dark:prose-invert">
1212
{{ partial "breadcrumbs.html" . }}
1313
<h1 class="scroll-mt-36">{{ .Title }}</h1>
14-
<table>
15-
<tbody>
16-
{{ with $data.short }}
17-
<tr>
18-
<th class="text-left w-32">Description</th>
19-
<td>{{ . }}</th>
20-
</tr>
21-
{{ end }}
22-
{{ with $data.usage }}
23-
<tr>
24-
<th class="text-left w-32">Usage</th>
25-
<td><code>{{ . }}</code></td>
26-
</tr>
27-
{{ end }}
28-
{{ with $data.aliases }}
29-
{{ $aliases := strings.Replace . (fmt.Printf "%s, " page.Title) "" }}
30-
<tr>
31-
<th class="text-left w-32 flex items-center gap-2">
32-
<span>Aliases</span>
33-
{{ partialCached "tooltip.html" "An alias is a short or memorable alternative for a longer command." "cli-alias" }}
34-
</th>
35-
<td>
36-
<div class="flex gap-3">
37-
{{ range (strings.Split $aliases ", ") }}
38-
<code>{{ . }}</code>
39-
{{ end }}
40-
</div>
41-
</td>
42-
</tr>
43-
{{ end }}
44-
</tbody>
45-
</table>
14+
<div class="overflow-x-auto">
15+
<table>
16+
<tbody>
17+
{{ with $data.short }}
18+
<tr>
19+
<th class="text-left w-32">Description</th>
20+
<td>{{ . }}</th>
21+
</tr>
22+
{{ end }}
23+
{{ with $data.usage }}
24+
<tr>
25+
<th class="text-left w-32">Usage</th>
26+
<td><code>{{ . }}</code></td>
27+
</tr>
28+
{{ end }}
29+
{{ with $data.aliases }}
30+
{{ $aliases := strings.Replace . (fmt.Printf "%s, " page.Title) "" }}
31+
<tr>
32+
<th class="text-left w-32 flex items-center gap-2">
33+
<span>Aliases</span>
34+
{{ partialCached "tooltip.html" "An alias is a short or memorable alternative for a longer command." "cli-alias" }}
35+
</th>
36+
<td>
37+
<div class="flex gap-3">
38+
{{ range (strings.Split $aliases ", ") }}
39+
<code>{{ . }}</code>
40+
{{ end }}
41+
</div>
42+
</td>
43+
</tr>
44+
{{ end }}
45+
</tbody>
46+
</table>
47+
</div>
4648
{{ .Content }}
4749
{{ if $data.deprecated }}
4850
{{ markdownify `
@@ -96,62 +98,64 @@ <h1 class="scroll-mt-36">{{ .Title }}</h1>
9698
{{ $heading := dict "level" 2 "text" "Options" }}
9799
{{ partialCached "heading.html" $heading "cli-options" }}
98100
{{ $.Scratch.Add "headings" $heading }}
99-
<table>
100-
<thead>
101-
<tr>
102-
<th>Option</th>
103-
<th>Default</th>
104-
<th>Description</th>
105-
</tr>
106-
</thead>
107-
<tbody>
108-
{{ range . }}
101+
<div class="overflow-x-auto">
102+
<table>
103+
<thead class="bg-gray-light-100 dark:bg-gray-dark-200">
109104
<tr>
110-
{{ $short := .shorthand }}
111-
{{ $long := .option }}
112-
<td>
113-
{{ with .details_url }}
114-
<a class="link" href="{{ . }}">
115-
<code>{{ with $short }}-{{ . }}, {{end}}--{{ $long }}</code>
116-
</a>
117-
{{ else }}
118-
<code>{{ with $short }}-{{ . }}, {{end}}--{{ $long }}</code>
119-
{{ end }}
120-
</td>
121-
{{ $skipDefault := `[],map[],false,0,0s,default,'',""` }}
122-
<td>
123-
{{ with .default_value }}
124-
{{ cond (in $skipDefault .) "" (printf "<code>%s</code>" . | safeHTML) }}
125-
{{ end }}
126-
</td>
127-
<td>
128-
{{ with .min_api_version }}
129-
{{ partialCached "components/badge.html" (dict "color" "blue" "content" (printf "API %s+" .)) "api" . }}
130-
{{ end }}
131-
{{ with .deprecated }}
132-
{{ partialCached "components/badge.html" (dict "color" "red" "content" "Deprecated") "deprecated" }}
133-
{{ end }}
134-
{{ with .experimental }}
135-
{{ partialCached "components/badge.html" (dict "color" "amber" "content" "experimental (daemon)") "exp" }}
136-
{{ end }}
137-
{{ with .experimentalcli }}
138-
{{ partialCached "components/badge.html" (dict "color" "amber" "content" "experimental (CLI)") "exp-cli" }}
139-
{{ end }}
140-
{{ with .kubernetes }}
141-
{{ partialCached "components/badge.html" (dict "color" "blue" "content" "Kubernetes") "k8s" }}
142-
{{ end }}
143-
{{ with .swarm }}
144-
{{ partialCached "components/badge.html" (dict "color" "blue" "content" "Swarm") "swarm" }}
145-
{{ end }}
146-
{{ if .description }}
147-
{{/* replace newlines in long desc with break tags */}}
148-
{{ markdownify (strings.Replace .description "\n" "<br>") }}
149-
{{ end }}
150-
</td>
105+
<th class="p-2">Option</th>
106+
<th class="p-2">Default</th>
107+
<th class="p-2">Description</th>
151108
</tr>
152-
{{ end }}
153-
</tbody>
154-
</table>
109+
</thead>
110+
<tbody>
111+
{{ range . }}
112+
<tr class="p-2">
113+
{{ $short := .shorthand }}
114+
{{ $long := .option }}
115+
<td>
116+
{{ with .details_url }}
117+
<a class="link" href="{{ . }}">
118+
<code>{{ with $short }}-{{ . }}, {{end}}--{{ $long }}</code>
119+
</a>
120+
{{ else }}
121+
<code>{{ with $short }}-{{ . }}, {{end}}--{{ $long }}</code>
122+
{{ end }}
123+
</td>
124+
{{ $skipDefault := `[],map[],false,0,0s,default,'',""` }}
125+
<td>
126+
{{ with .default_value }}
127+
{{ cond (in $skipDefault .) "" (printf "<code>%s</code>" . | safeHTML) }}
128+
{{ end }}
129+
</td>
130+
<td>
131+
{{ with .min_api_version }}
132+
{{ partialCached "components/badge.html" (dict "color" "blue" "content" (printf "API %s+" .)) "api" . }}
133+
{{ end }}
134+
{{ with .deprecated }}
135+
{{ partialCached "components/badge.html" (dict "color" "red" "content" "Deprecated") "deprecated" }}
136+
{{ end }}
137+
{{ with .experimental }}
138+
{{ partialCached "components/badge.html" (dict "color" "amber" "content" "experimental (daemon)") "exp" }}
139+
{{ end }}
140+
{{ with .experimentalcli }}
141+
{{ partialCached "components/badge.html" (dict "color" "amber" "content" "experimental (CLI)") "exp-cli" }}
142+
{{ end }}
143+
{{ with .kubernetes }}
144+
{{ partialCached "components/badge.html" (dict "color" "blue" "content" "Kubernetes") "k8s" }}
145+
{{ end }}
146+
{{ with .swarm }}
147+
{{ partialCached "components/badge.html" (dict "color" "blue" "content" "Swarm") "swarm" }}
148+
{{ end }}
149+
{{ if .description }}
150+
{{/* replace newlines in long desc with break tags */}}
151+
{{ markdownify (strings.Replace .description "\n" "<br>") }}
152+
{{ end }}
153+
</td>
154+
</tr>
155+
{{ end }}
156+
</tbody>
157+
</table>
158+
</div>
155159
{{ end }}
156160
{{ end }}
157161
{{ with $data.examples }}

0 commit comments

Comments
 (0)