diff options
author | Tyler Lawson <tylerjlawson2@gmail.com> | 2021-06-26 18:41:06 +0300 |
---|---|---|
committer | Tyler Lawson <tylerjlawson2@gmail.com> | 2021-06-26 18:41:06 +0300 |
commit | 7fae22267110bde22a8ac2946395b7610c0c7d17 (patch) | |
tree | 7769206220327fe59c2b176b2c95b52240d4815b | |
parent | 49a3c6a29e47917cbcafa348ddb0e246894ae43a (diff) |
adding support for list with one level sublist
-rw-r--r-- | exampleSite/data/content.yaml | 2 | ||||
-rw-r--r-- | layouts/partials/bullet-list.html | 16 | ||||
-rw-r--r-- | layouts/partials/section.html | 16 |
3 files changed, 20 insertions, 14 deletions
diff --git a/exampleSite/data/content.yaml b/exampleSite/data/content.yaml index 9feeb63..c05fa36 100644 --- a/exampleSite/data/content.yaml +++ b/exampleSite/data/content.yaml @@ -32,6 +32,8 @@ sections: enddate: Jun 2008 points: - 'Started in a comedy duo with Jack Burns, a fellow DJ from Texas' + - - Jack was pretty cool + - He was funny and stuff - >- Arrested with Lenny Bruce when he told the police that he did not believe in government issues IDs diff --git a/layouts/partials/bullet-list.html b/layouts/partials/bullet-list.html new file mode 100644 index 0000000..25b4832 --- /dev/null +++ b/layouts/partials/bullet-list.html @@ -0,0 +1,16 @@ +{{ with . }} + <ul> + {{ $array := . }} + {{ range $index, $value := . }} + {{ if eq (printf "%T" $value) "string" }} + <li> + {{ $value | markdownify }} + {{ $next := (index $array (add 1 $index)) }} + {{ if eq (printf "%T" $next) "[]interface {}" }} + {{ partial "bullet-list.html" $next }} + {{ end }} + </li> + {{ end }} + {{ end }} + </ul> +{{ end }} diff --git a/layouts/partials/section.html b/layouts/partials/section.html index 6dcf406..c49bc51 100644 --- a/layouts/partials/section.html +++ b/layouts/partials/section.html @@ -1,13 +1,7 @@ <section> <h2>{{ .heading }}</h2> {{ with .body }}<p>{{ . }}</p>{{ end }} - {{ with .points }} - <ul> - {{ range . }} - <li>{{ . | markdownify }}</li> - {{ end }} - </ul> - {{ end }} + {{ partial "bullet-list.html" .points }} {{ range .subsections }} <div> {{ with .heading }} @@ -24,13 +18,7 @@ <em>{{ . }}</em> </p> {{ end }} - {{ with .points }} - <ul> - {{ range . }} - <li>{{ . | markdownify }}</li> - {{ end }} - </ul> - {{ end }} + {{ partial "bullet-list.html" .points }} </div> {{ end }} </section> |