Files
libertytoolsio/themes/hugo-book.backup/layouts/_shortcodes/columns.html

34 lines
1.2 KiB
HTML

{{- $ratio := (split (.Get "ratio") ":") -}}
{{- if strings.Contains .InnerDeindent "<--->" -}}
{{- warnf "Columns shortcode seprator '<--->' is deprecated, use markdown list instead." -}}
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"merge" (dict
"class" (slice "book-columns" "flex" "flex-wrap")
)
) -}}
<div {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>
{{- range $index, $content := split .InnerDeindent "<--->" -}}
{{- $grow := default 1 (index $ratio $index) -}}
<div class="flex-even markdown-inner" style="flex-grow: {{ $grow }};">
{{- $content | safeHTML -}}
</div>
{{- end -}}
</div>
{{- else -}}
{{- if .Get "ratio" -}}<style>{{- range $index, $grow := $ratio -}}
.book-columns-{{ $.Ordinal }}>ul>li:nth-child({{ $index | add 1 }}){
flex-grow: {{ default 1 $grow }};
}
{{- end -}}</style>{{- end -}}
{{- $attributes := partial "docs/text/mapper" (dict
"attributes" (cond .IsNamedParams .Params dict)
"merge" (dict
"class" (slice "book-columns")
)
) -}}
<div {{ partial "docs/html-attrs" $attributes | safeHTMLAttr }}>
{{ .Inner | safeHTML -}}
</div>
{{- end -}}