diff --git a/wowchemy/layouts/_default/list.html b/wowchemy/layouts/_default/list.html index 9537c452..ea7ee996 100644 --- a/wowchemy/layouts/_default/list.html +++ b/wowchemy/layouts/_default/list.html @@ -8,17 +8,9 @@ {{ end }} {{ $paginator := .Paginate .Pages }} - {{ range $paginator.Pages }} - {{ if eq $.Params.view 1 }} - {{ partial "li_list" . }} - {{ else if eq $.Params.view 3 }} - {{ partial "li_card" . }} - {{ else if eq $.Params.view 4 }} - {{ partial "li_citation" . }} - {{ else }} - {{ partial "li_compact" . }} - {{ end }} - {{ end }} + {{ range $index, $post := $paginator.Pages }} + {{ partial "functions/render_view" (dict "page" $ "item" . "view" ($.Params.view | default "compact") "index" $index) }} + {{end}} {{ partial "pagination" . }} diff --git a/wowchemy/layouts/partials/functions/render_view.html b/wowchemy/layouts/partials/functions/render_view.html new file mode 100644 index 00000000..73a5058d --- /dev/null +++ b/wowchemy/layouts/partials/functions/render_view.html @@ -0,0 +1,31 @@ +{{/* Wowchemy content preview renderer */}} + +{{ $page := .page }} +{{ $item := .item }} +{{ $view := .view }} +{{ $view_file := "" }} +{{ $view_dtype := printf "%T" $view }} +{{ $index := .index }} + +{{if eq $view_dtype "int" }} + {{/* Support legacy numeric views 1-4 */}} + {{ if eq $view 1 }} + {{ $view_file = "list" }} + {{ else if eq $view 3 }} + {{ $view_file = "card" }} + {{ else if eq $view 4 }} + {{ $view_file = "citation" }} + {{ else }} + {{ $view_file = "compact" }} + {{ end }} +{{else}} + {{ if templates.Exists (printf "partials/views/%s.html" (lower $view)) }} + {{ $view_file = lower $view }} + {{else}} + {{/* Fallback to compact view */}} + {{ warnf "Failed to locate view at `partials/views/%s.html`. Check you specified a supported `view` in `%s`" $view $page.File.Path }} + {{ $view_file = "compact" }} + {{end}} +{{ end }} + +{{ return (partial (printf "views/%s" $view_file) (dict "page" $page "item" $item "index" $index)) }} diff --git a/wowchemy/layouts/partials/li_citation.html b/wowchemy/layouts/partials/li_citation.html deleted file mode 100644 index 20b68213..00000000 --- a/wowchemy/layouts/partials/li_citation.html +++ /dev/null @@ -1,42 +0,0 @@ -{{ $has_attachments := partial "functions/has_attachments" . }} - -
- - - {{/* APA Style */}} - {{ if eq (site.Params.publications.citation_style | default "apa") "apa" }} - - - {{ partial "page_metadata_authors" . }} - - ({{- .Date.Format "2006" -}}). - {{ .Title }}. - {{ if .Params.publication_short }} - {{- .Params.publication_short | markdownify -}}. - {{ else if .Params.publication }} - {{- .Params.publication | markdownify -}}. - {{ end }} -

{{ partial "page_links" (dict "page" . "is_list" 1) }}

- - {{/* MLA Style */}} - {{ else }} - - - {{ partial "page_metadata_authors" . }}. - - {{ .Title }}. - {{ if .Params.publication_short }} - {{- .Params.publication_short | markdownify -}}, - {{ else if .Params.publication }} - {{- .Params.publication | markdownify -}}, - {{ end }} - {{- .Date.Format "2006" -}}. - - {{ if $has_attachments }} - - {{ end }} - - {{ end }} -
diff --git a/wowchemy/layouts/partials/li_card.html b/wowchemy/layouts/partials/views/card.html similarity index 96% rename from wowchemy/layouts/partials/li_card.html rename to wowchemy/layouts/partials/views/card.html index b51ec077..8361d7f6 100644 --- a/wowchemy/layouts/partials/li_card.html +++ b/wowchemy/layouts/partials/views/card.html @@ -1,4 +1,4 @@ -{{ $item := . }} +{{ $item := .item }} {{/* Dynamic view adjusts to content type. */}} {{ $has_attachments := partial "functions/has_attachments" . }} @@ -13,7 +13,7 @@ {{ $summary = $item.Summary }} {{ end }} -
+
{{ if eq $item.Type "event" }}