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" . }} - -
{{ partial "page_links" (dict "page" . "is_list" 1) }}
- - {{/* MLA Style */}} - {{ else }} - - - {{ .Title }}. - {{ if .Params.publication_short }} - {{- .Params.publication_short | markdownify -}}, - {{ else if .Params.publication }} - {{- .Params.publication | markdownify -}}, - {{ end }} - {{- .Date.Format "2006" -}}. - - {{ if $has_attachments }} -