diff --git a/assets/theme-css/lists.css b/assets/theme-css/lists.css new file mode 100644 index 00000000..a34bd5cc --- /dev/null +++ b/assets/theme-css/lists.css @@ -0,0 +1,18 @@ +dl.field-list { + display: grid; + grid-template-columns: fit-content(30%) auto; +} + +dl.field-list > dt { + font-weight: bold; + word-break: break-word; + padding-left: 0.5em; + padding-right: 5px; +} + +dl.field-list > dd { + padding-left: 0.5em; + margin-top: 0em; + margin-left: 0em; + margin-bottom: 0em; +} diff --git a/layouts/partials/field-list.html b/layouts/partials/field-list.html new file mode 100644 index 00000000..8e18183c --- /dev/null +++ b/layouts/partials/field-list.html @@ -0,0 +1,16 @@ +{{ $m := slice + (dict "term" "John" "def" 30) + (dict "term" "Will" "def" 28) + (dict "term" "Joey" "def" 24) +}} +
+{{ range $i, $entry := .entries }} + {{if (modBool $i 2)}} +
{{ .term }}:
+
{{ .def }}
+ {{else}} +
{{ .term }}:
+
{{ .def }}
+ {{end}} +{{end}} +
diff --git a/layouts/shortcodes/field-list.html b/layouts/shortcodes/field-list.html new file mode 100644 index 00000000..9bdb64d6 --- /dev/null +++ b/layouts/shortcodes/field-list.html @@ -0,0 +1,22 @@ +{{/* + +doc: Field lists + +{{< field-list >}} +[[entry]] +term = "John" +def = 30 + +[[entry]] +term = "Will" +def = 28 + +[[entry]] +term = "Joey" +def = 24 +{{< /field-list >}} + +*/}} + +{{ $entries := (index (.Inner | transform.Unmarshal) "entry") }} +{{ partial "field-list" (dict "ctx" . "entries" $entries) }}