diff --git a/modules/wowchemy/layouts/index.html b/modules/wowchemy/layouts/index.html index d58663c4..d70b7e4e 100644 --- a/modules/wowchemy/layouts/index.html +++ b/modules/wowchemy/layouts/index.html @@ -18,10 +18,11 @@ {{/* Generate homepage. */}} {{ if eq .Type "book" }} {{ partial "book_layout.html" . }} -{{ else if eq .Type "widget_page" }} - {{ partial "widget_page.html" . }} -{{ else }} +{{ else if eq .Type "landing" }} {{ partial "landing_page.html" . }} +{{ else }} + {{/* If no homepage file is present, fallback to legacy widget page */}} + {{ partial "widget_page.html" . }} {{ end }} {{- end -}} diff --git a/modules/wowchemy/layouts/partials/blocks/collection.html b/modules/wowchemy/layouts/partials/blocks/collection.html new file mode 100644 index 00000000..519d34c8 --- /dev/null +++ b/modules/wowchemy/layouts/partials/blocks/collection.html @@ -0,0 +1,121 @@ +{{/* Wowchemy Blocks: Collection */}} +{{/* Documentation: https://wowchemy.com/blocks/ */}} +{{/* License: https://github.com/wowchemy/wowchemy-hugo-themes/blob/main/LICENSE.md */}} + +{{/* Initialise */}} +{{ $page := .wcPage }} +{{ $block := .wcBlock }} + +{{ $items_offset := $block.content.offset | default 0 }} +{{ $items_count := $block.content.count }} +{{ if eq $items_count 0 }} + {{ $items_count = 65535 }} +{{ else }} + {{ $items_count = $items_count | default 5 }} +{{ end }} + +{{/* Query */}} +{{ $query := site.RegularPages }} +{{ $archive_page := "" }} + +{{/* Filters */}} +{{ if $block.content.page_type }} + {{ $query = where $query "Type" $block.content.page_type }} + {{ $archive_page = site.GetPage "Section" $block.content.page_type }} +{{ end }} +{{ if $block.content.filters.folders }} + {{ $folders := $block.content.filters.folders }} + {{ $query = where $query "Section" "in" $folders }} + {{/* Init archive page to main folder */}} + {{ $main_folder := index $folders 0 }} + {{ $archive_page = site.GetPage "Section" $main_folder }} +{{ end }} +{{ if $block.content.filters.tag }} + {{ $archive_page = site.GetPage (printf "tags/%s" (urlize $block.content.filters.tag)) }} + {{ $query = $query | intersect $archive_page.Pages }} +{{ end }} +{{ if $block.content.filters.category }} + {{ $archive_page = site.GetPage (printf "categories/%s" (urlize $block.content.filters.category)) }} + {{ $query = $query | intersect $archive_page.Pages }} +{{ end }} +{{ if $block.content.filters.publication_type }} + {{ $archive_page = site.GetPage (printf "publication_types/%s" $block.content.filters.publication_type) }} + {{ $query = $query | intersect $archive_page.Pages }} +{{ end }} +{{ if $block.content.filters.author }} + {{ $archive_page = site.GetPage (printf "authors/%s" (urlize $block.content.filters.author)) }} + {{ $query = $query | intersect $archive_page.Pages }} +{{ end }} +{{ if $block.content.filters.featured_only }} + {{ $query = where $query "Params.featured" "==" true }} +{{ end }} +{{ if $block.content.filters.exclude_featured }} + {{ $query = where $query "Params.featured" "!=" true }} +{{ end }} +{{ if $block.content.filters.exclude_past }} + {{ $query = where $query "Date" ">=" now }} +{{ end }} +{{ if $block.content.filters.exclude_future }} + {{ $query = where $query "Date" "<" now }} +{{ end }} + +{{ $count := len $query }} + +{{/* Sort */}} +{{ $sort_by := $block.content.sort_by | default "Date" }} +{{ $sort_ascending := $block.content.sort_ascending | default (eq $block.content.order "asc") | default false }} +{{ $sort_order := cond $sort_ascending "asc" "desc" }} +{{ $query = sort $query $sort_by $sort_order }} + +{{/* Offset and Limit */}} +{{ if gt $items_offset 0 }} + {{ $query = first $items_count (after $items_offset $query) }} +{{ else }} + {{ $query = first $items_count $query }} +{{ end }} + +{{ $columns := $block.design.columns | default "2" }} + +
{{ . | markdownify | emojify }}
{{ end }} + {{ with $block.content.title }}{{ . | markdownify | emojify }}
{{ end }}{{ . | markdownify | emojify }}
{{ end }} + {{ with $block.content.title }}{{ . | markdownify | emojify }}
{{ end }}