Re-implement columns shortcode as markdown list

This commit is contained in:
Alex Shpak
2025-08-05 13:29:30 +02:00
parent 5f2dbb76fa
commit 2c8c093a30
3 changed files with 69 additions and 56 deletions
+12
View File
@@ -1,4 +1,6 @@
{{- $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) -}}
@@ -7,3 +9,13 @@
</div>
{{ end }}
</div>
{{ else }}
<div class="book-columns book-columns-{{ .Ordinal }} {{ with .Get "class" }}{{ . }}{{ end }}">
<style>{{- range $index, $grow := $ratio -}}
.book-columns-{{ $.Ordinal }}>ul>li:nth-child({{ $index | add 1 }}){
flex-grow: {{ $grow }};
}
{{ end -}}</style>
{{ .Inner | safeHTML }}
</div>
{{ end -}}