Files
hugo-book/layouts/_shortcodes/columns.html

22 lines
882 B
HTML

{{- $ratio := (split (.Get "ratio") ":") -}}
{{- if strings.Contains .InnerDeindent "<--->" -}}
{{- warnf "Columns shortcode seprator '<--->' is deprecated, use markdown list instead." -}}
<div class="book-columns flex flex-wrap{{ with .Get "class" }} {{ . }}{{ end }}">
{{- 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 -}}
<div class="book-columns book-columns-{{ .Ordinal }}{{ with .Get "class" }} {{ . }}{{ end }}">
{{ .Inner | safeHTML -}}
</div>
{{- end -}}