From 751fddc8f154b9fe60d1d3a7b087a3ee6771d34d Mon Sep 17 00:00:00 2001 From: razonyang Date: Thu, 29 Jun 2023 16:16:19 +0800 Subject: [PATCH] feat: add the row and col shortcodes --- layouts/partials/bootstrap/col.html | 41 +++++++++++++++++++++++++++ layouts/partials/bootstrap/row.html | 24 ++++++++++++++++ layouts/shortcodes/bootstrap/col.html | 2 ++ layouts/shortcodes/bootstrap/row.html | 2 ++ layouts/shortcodes/bs/col.html | 2 ++ layouts/shortcodes/bs/row.html | 2 ++ 6 files changed, 73 insertions(+) create mode 100644 layouts/partials/bootstrap/col.html create mode 100644 layouts/partials/bootstrap/row.html create mode 100644 layouts/shortcodes/bootstrap/col.html create mode 100644 layouts/shortcodes/bootstrap/row.html create mode 100644 layouts/shortcodes/bs/col.html create mode 100644 layouts/shortcodes/bs/row.html diff --git a/layouts/partials/bootstrap/col.html b/layouts/partials/bootstrap/col.html new file mode 100644 index 0000000..6b22fc0 --- /dev/null +++ b/layouts/partials/bootstrap/col.html @@ -0,0 +1,41 @@ +{{- $size := "" }} +{{- $offset := "" }} +{{- $class := "" }} +{{- if .IsNamedParams }} + {{- with .Get "size" }}{{ $size = . }}{{ end }} + {{- with .Get "offset" }}{{ $offset = . }}{{ end }} + {{- with .Get "class" }}{{ $class = . }}{{ end }} +{{- else }} + {{- with .Get 0 }}{{ $size = . }}{{ end }} + {{- with .Get 1 }}{{ $offset = . }}{{ end }} + {{- with .Get 2 }}{{ $class = . }}{{ end }} +{{- end }} +{{- $classes := slice }} +{{- with $size }} + {{- $sizes := split . " " }} + {{- range $sizes }} + {{- $kv := split . ":" }} + {{- if gt (len $kv) 1 }} + {{- $classes = $classes | append (printf "col-%s-%s" (index $kv 0) (index $kv 1)) }} + {{- else }} + {{- $classes = $classes | append (printf "col-%s" .) }} + {{- end }} + {{- end }} +{{- else }} + {{- $classes = $classes | append "col" }} +{{- end }} +{{- with $offset }} + {{- $offsets := split . " " }} + {{- range $offsets }} + {{- $kv := split . ":" }} + {{- if gt (len $kv) 1 }} + {{- $classes = $classes | append (printf "offset-%s-%s" (index $kv 0) (index $kv 1)) }} + {{- else }} + {{- $classes = $classes | append (printf "offset-%s" .) }} + {{- end }} + {{- end }} +{{- end }} +{{- with $class }}{{ $classes = $classes | append . }}{{ end }} +
+ {{ .Inner }} +
diff --git a/layouts/partials/bootstrap/row.html b/layouts/partials/bootstrap/row.html new file mode 100644 index 0000000..724c2ce --- /dev/null +++ b/layouts/partials/bootstrap/row.html @@ -0,0 +1,24 @@ +{{- $cols := "" }} +{{- $class := "" }} +{{- if .IsNamedParams }} + {{- with .Get "cols" }}{{ $class = . }}{{ end }} + {{- with .Get "class" }}{{ $class = . }}{{ end }} +{{- else }} + {{- with .Get 0 }}{{ $cols = . }}{{ end }} + {{- with .Get 1 }}{{ $class = . }}{{ end }} +{{- end }} +{{- $classes := slice "row" }} +{{- with $cols }} + {{- range split . " " }} + {{- $kv := split . ":" }} + {{- if gt (len $kv) 1 }} + {{- $classes = $classes | append (printf "row-cols-%s-%s" (index $kv 0) (index $kv 1)) }} + {{- else }} + {{- $classes = $classes | append (printf "row-cols-%s" .) }} + {{- end }} + {{- end }} +{{- end }} +{{- with $class }}{{ $classes = $classes | append . }}{{ end }} +
+ {{ .Inner }} +
diff --git a/layouts/shortcodes/bootstrap/col.html b/layouts/shortcodes/bootstrap/col.html new file mode 100644 index 0000000..d11c39e --- /dev/null +++ b/layouts/shortcodes/bootstrap/col.html @@ -0,0 +1,2 @@ +{{- if .Inner }}{{ end }} +{{- partial "bootstrap/col" . }} diff --git a/layouts/shortcodes/bootstrap/row.html b/layouts/shortcodes/bootstrap/row.html new file mode 100644 index 0000000..66a5450 --- /dev/null +++ b/layouts/shortcodes/bootstrap/row.html @@ -0,0 +1,2 @@ +{{- if .Inner }}{{ end }} +{{- partial "bootstrap/row" . }} diff --git a/layouts/shortcodes/bs/col.html b/layouts/shortcodes/bs/col.html new file mode 100644 index 0000000..d11c39e --- /dev/null +++ b/layouts/shortcodes/bs/col.html @@ -0,0 +1,2 @@ +{{- if .Inner }}{{ end }} +{{- partial "bootstrap/col" . }} diff --git a/layouts/shortcodes/bs/row.html b/layouts/shortcodes/bs/row.html new file mode 100644 index 0000000..66a5450 --- /dev/null +++ b/layouts/shortcodes/bs/row.html @@ -0,0 +1,2 @@ +{{- if .Inner }}{{ end }} +{{- partial "bootstrap/row" . }}