mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-12 20:15:25 +00:00
See https://discord.com/channels/722225264733716590/738924091511144489/1406144559188283494 See https://gohugo.io/templates/new-templatesystem-overview/
34 lines
1.0 KiB
HTML
34 lines
1.0 KiB
HTML
{{/* Hugo Blox Builder content preview renderer */}}
|
|
|
|
{{ $page := .page }}
|
|
{{ $item := .item }}
|
|
{{ $view := .view }}
|
|
{{ $view_file := "" }}
|
|
{{ $view_dtype := printf "%T" $view }}
|
|
{{ $index := .index }}
|
|
|
|
{{if eq $view_dtype "int" | or (eq $view_dtype "int64") }}
|
|
{{/* Support legacy numeric views 1-5 */}}
|
|
{{ if eq $view 1 }}
|
|
{{ $view_file = "list" }}
|
|
{{ else if eq $view 3 }}
|
|
{{ $view_file = "card" }}
|
|
{{ else if eq $view 4 }}
|
|
{{ $view_file = "citation" }}
|
|
{{ else if eq $view 5 }}
|
|
{{ $view_file = "showcase" }}
|
|
{{ 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)) }}
|