diff --git a/modules/wowchemy/layouts/partials/widgets/tag_cloud.html b/modules/wowchemy/layouts/partials/blocks/tag_cloud.html
similarity index 67%
rename from modules/wowchemy/layouts/partials/widgets/tag_cloud.html
rename to modules/wowchemy/layouts/partials/blocks/tag_cloud.html
index a9c0a803..98578219 100644
--- a/modules/wowchemy/layouts/partials/widgets/tag_cloud.html
+++ b/modules/wowchemy/layouts/partials/blocks/tag_cloud.html
@@ -1,11 +1,15 @@
-{{/* Initialise */}}
-{{ $ := .root }}
-{{ $st := .page }}
-{{ $taxonomy := $st.Params.content.taxonomy | default "tags" }}
-{{ $fontSmall := $st.Params.design.font_size_min | default 0.8 }}
-{{ $fontBig := $st.Params.design.font_size_max | default 2.5 }}
+{{/* Wowchemy Blocks: Tag Cloud */}}
+{{/* Documentation: https://wowchemy.com/blocks/ */}}
+{{/* License: https://github.com/wowchemy/wowchemy-hugo-themes/blob/main/LICENSE.md */}}
-{{ $items_count := $st.Params.content.count }}
+{{/* Initialise */}}
+{{ $page := .wcPage }}
+{{ $block := .wcBlock }}
+{{ $taxonomy := $block.Params.content.taxonomy | default "tags" }}
+{{ $fontSmall := $block.Params.design.font_size_min | default 0.8 }}
+{{ $fontBig := $block.Params.design.font_size_max | default 2.5 }}
+
+{{ $items_count := $block.Params.content.count }}
{{ if eq $items_count 0 }}
{{ $items_count = 65535 }}
{{ else }}
@@ -16,10 +20,10 @@
{{ $tags := first $items_count (index site.Taxonomies $taxonomy).ByCount }}
{{ $count := len $tags }}
-{{ $columns := $st.Params.design.columns | default "2" }}
+{{ $columns := $block.Params.design.columns | default "2" }}
- {{ with $st.Content }}{{ . }}{{ end }}
+ {{ with $block.Content }}{{ . }}{{ end }}
{{ if ne $count 0 }}
diff --git a/modules/wowchemy/layouts/partials/functions/parse_block.html b/modules/wowchemy/layouts/partials/functions/parse_block.html
new file mode 100644
index 00000000..8223f336
--- /dev/null
+++ b/modules/wowchemy/layouts/partials/functions/parse_block.html
@@ -0,0 +1,144 @@
+{{/* Wowchemy Block Parser */}}
+{{/* Documentation: https://wowchemy.com/blocks/ */}}
+{{/* License: https://github.com/wowchemy/wowchemy-hugo-themes/blob/main/LICENSE.md */}}
+
+{{ $page := .page }}
+{{ $block := .block }}
+
+{{ $block_type := lower $block.Params.widget | default "markdown" }}
+{{ if eq $block_type "blank" }}{{ $block_type = "markdown" }}{{ end }}{{/* Support legacy Blank block */}}
+{{ if eq $block_type "featurette" }}{{ $block_type = "features" }}{{ end }}{{/* Support legacy Featurette block */}}
+{{ if eq $block_type "pages" }}{{ $block_type = "collection" }}{{ end }}{{/* Support legacy Pages block */}}
+{{ if eq $block_type "featured" }}{{ $block_type = "collection" }}{{ end }}{{/* Support legacy Featured block */}}
+{{ $widget_path := printf "blocks/%s.html" $block_type }}
+{{ if not (templates.Exists (printf "partials/%s" $widget_path)) }}
+ {{ errorf "%s uses a `%s` block but the `%s` block was not found at `layouts/partials/%s`" $block.File.Path $block_type $block_type $widget_path }}
+{{ end }}
+
+{{/* Workaround to make Hugo's .Page.Store.Set cascade up to the parent of headless pages */}}
+{{ if $block.Page.Store.Get "has_mermaid" }}
+ {{ $page.Page.Store.Set "has_mermaid" true }}
+{{ end }}
+
+{{/* Begin widget styling */}}
+{{ $bg := $block.Params.design.background }}
+{{ $style := "" }}
+{{ $style_bg := "" }}
+
+{{ if $bg.color }}
+ {{ $style_bg = printf "background-color: %s;" ($bg.color | default "transparent") }}
+{{ end }}
+
+{{ if and $bg.gradient_start $bg.gradient_end }}
+ {{ $angle := string $bg.gradient_angle | default "90" }}
+ {{ $style_bg = printf "%sbackground-image: linear-gradient(%sdeg, %s, %s);" $style_bg $angle $bg.gradient_start $bg.gradient_end }}
+{{ end }}
+
+{{ $bg_video := "" }}
+{{ if $bg.video.path }}
+ {{ $bg_video = resources.Get (printf "media/%s" $bg.video.path) }}
+{{ end }}
+{{ $bg_video_class := "" }}
+{{ if $bg.video.flip }}
+ {{ $bg_video_class = "flip" }}
+{{ end }}
+
+{{ if $bg.image }}
+ {{/* See Hugo note on linking assets in styles: https://github.com/gohugoio/hugoThemes#common-permalink-issues */}}
+ {{ $bg_img := resources.Get (printf "media/%s" $bg.image) }}
+ {{ if $bg_img }}
+ {{/* Exception for SVG as Hugo doesn't yet support image processing on SVG. */}}
+ {{ if ne $bg_img.MediaType.SubType "svg" }}
+ {{ $bg_img = $bg_img.Fit "1920x1920 webp" }}
+ {{ end }}
+ {{ $style_bg = printf "%sbackground-image: url('%s');" $style_bg $bg_img.Permalink }}
+ {{ else }}
+ {{ errorf "Couldn't find `%s` in the `assets/media/` folder - please add it." $bg.image }}
+ {{ end }}
+ {{ with $bg.image_size }}
+ {{/* Allow sizes: actual, cover, and contain. */}}
+ {{ $style_bg = printf "%sbackground-size: %s;" $style_bg (replace . "actual" "auto") }}
+ {{ end }}
+ {{ with $bg.image_position }}
+ {{/* Allow valid CSS positions including left, center, and right. */}}
+ {{ $style_bg = printf "%sbackground-position: %s;" $style_bg . }}
+ {{ end }}
+{{ end }}
+
+{{ if $bg.image_darken }}
+ {{ $style_bg = printf "%sfilter: brightness(%s);" $style_bg (string $bg.image_darken) }}
+{{ end }}
+
+{{ with $block.Params.design.spacing.padding }}
+ {{ $style_pad := printf "padding: %s;" (delimit . " ") }}
+ {{ $style = print $style $style_pad }}
+{{ end }}
+
+{{/* Support for clip path (design.clip_path) */}}
+{{ with $block.Params.design.clip_path }}
+ {{ $style_clip_path := printf "clip-path: %s;" . }}
+ {{ $style = print $style $style_clip_path }}
+{{ end }}
+
+{{ with ($block.Params.design.css_style | default $block.Params.advanced.css_style) }}
+ {{ $style = print $style . }}
+{{ end }}
+
+{{/* Fix Hugo's ContentBaseName returning wrong file base name when page section is within a bundle. */}}
+{{ $hash_id := replace $block.File.ContentBaseName "index" (path.Base .File.Dir) }}
+
+{{ $widget_args := dict "wcPage" $page "wcBlock" $block "wcIdentifier" $hash_id }}
+{{ $css_classes := $block.Params.design.css_class | default $block.Params.advanced.css_class | default "" }}
+{{ $extra_attributes := "" }}
+{{ $use_container := true }}
+
+{{/* Special case: Slider widget. */}}
+{{ if in (slice "slider") $block_type }}
+ {{ $css_classes = print $css_classes " carousel slide" }}
+ {{ $extra_attributes = printf "data-ride=\"carousel\" data-interval=\"%s\"" (cond ($block.Params.design.loop | default true) (string $block.Params.design.interval | default "3000") "false") }}
+ {{ $use_container = false }}
+{{ end }}
+
+{{ $widget_class := printf "wg-%s" (replace (replace $block_type "." "-") "_" "-") }}
+
+{{ $widget_config_file := printf "widgets/%s-config.html" $block_type }}
+{{ if templates.Exists $widget_config_file }}
+ {{ $cfg := partial $widget_config_file $widget_args }}
+ {{ $use_container = $cfg.use_container }}
+{{end}}
+
+{{ $columns := $block.Params.design.columns | default "2" }}
+{{ $use_cols := in (slice "collection" "experience" "accomplishments" "contact" "markdown" "tag_cloud" "portfolio") $block_type }}
+
+{{/* Dedicated child div for bg prevents parallax 100% height issue within new CSS grid page wrapper. */}}
+
+
+ {{with $bg_video}}{{end}}
+
+ {{if $use_container}}{{end}}
+
+ {{if $use_cols}}
+
+ {{ if $block.Title }}
+ {{ if eq $columns "1" }}
+
+ {{ with $block.Title }}
{{ . | markdownify | emojify }}
{{ end }}
+ {{ with $block.Params.subtitle }}
{{ . | markdownify | emojify }}
{{ end }}
+
+ {{else}}
+
+ {{ with $block.Title }}
{{ . | markdownify | emojify }}
{{ end }}
+ {{ with $block.Params.subtitle }}
{{ . | markdownify | emojify }}
{{ end }}
+
+ {{end}}
+ {{end}}
+ {{end}}
+
+ {{ partial $widget_path $widget_args }}
+
+ {{if $use_cols}}
+
+ {{end}}
+
+ {{if $use_container}}
{{end}}
+
diff --git a/modules/wowchemy/layouts/partials/widget_page.html b/modules/wowchemy/layouts/partials/widget_page.html
index 56926dfb..64bcb7f9 100644
--- a/modules/wowchemy/layouts/partials/widget_page.html
+++ b/modules/wowchemy/layouts/partials/widget_page.html
@@ -1,7 +1,8 @@
{{/* Notify JS that this is a widget page */}}
+
-{{/* Get widget page */}}
+{{/* Load widget page */}}
{{ $page := "" }}
{{ $headless_bundle := "" }}
{{ if .IsHome }}
@@ -25,144 +26,7 @@
{{ end }}
{{ end }}
-{{/* Load page sections */}}
-{{ $has_mermaid := false }}
-{{ range $index, $st := where ( $headless_bundle.Resources.ByType "page" ) ".Params.active" "!=" false }}
- {{ if .Page.Store.Get "has_mermaid" }}
- {{ $has_mermaid = true }}
- {{ end }}
-
- {{/* Begin widget styling */}}
- {{ $bg := $st.Params.design.background }}
- {{ $style := "" }}
- {{ $style_bg := "" }}
-
- {{ if $bg.color }}
- {{ $style_bg = printf "background-color: %s;" ($bg.color | default "transparent") }}
- {{ end }}
-
- {{ if and $bg.gradient_start $bg.gradient_end }}
- {{ $angle := string $bg.gradient_angle | default "90" }}
- {{ $style_bg = printf "%sbackground-image: linear-gradient(%sdeg, %s, %s);" $style_bg $angle $bg.gradient_start $bg.gradient_end }}
- {{ end }}
-
- {{ $bg_video := "" }}
- {{ if $bg.video.path }}
- {{ $bg_video = resources.Get (printf "media/%s" $bg.video.path) }}
- {{ end }}
- {{ $bg_video_class := "" }}
- {{ if $bg.video.flip }}
- {{ $bg_video_class = "flip" }}
- {{ end }}
-
- {{ if $bg.image }}
- {{/* See Hugo note on linking assets in styles: https://github.com/gohugoio/hugoThemes#common-permalink-issues */}}
- {{ $bg_img := resources.Get (printf "media/%s" $bg.image) }}
- {{ if $bg_img }}
- {{/* Exception for SVG as Hugo doesn't yet support image processing on SVG. */}}
- {{ if ne $bg_img.MediaType.SubType "svg" }}
- {{ $bg_img = $bg_img.Fit "1920x1920 webp" }}
- {{ end }}
- {{ $style_bg = printf "%sbackground-image: url('%s');" $style_bg $bg_img.Permalink }}
- {{ else }}
- {{ errorf "Couldn't find `%s` in the `assets/media/` folder - please add it." $bg.image }}
- {{ end }}
- {{ with $bg.image_size }}
- {{/* Allow sizes: actual, cover, and contain. */}}
- {{ $style_bg = printf "%sbackground-size: %s;" $style_bg (replace . "actual" "auto") }}
- {{ end }}
- {{ with $bg.image_position }}
- {{/* Allow valid CSS positions including left, center, and right. */}}
- {{ $style_bg = printf "%sbackground-position: %s;" $style_bg . }}
- {{ end }}
- {{ end }}
-
- {{ if $bg.image_darken }}
- {{ $style_bg = printf "%sfilter: brightness(%s);" $style_bg (string $bg.image_darken) }}
- {{ end }}
-
- {{ with $st.Params.design.spacing.padding }}
- {{ $style_pad := printf "padding: %s;" (delimit . " ") }}
- {{ $style = print $style $style_pad }}
- {{ end }}
-
- {{/* Support for clip path (design.clip_path) */}}
- {{ with $st.Params.design.clip_path }}
- {{ $style_clip_path := printf "clip-path: %s;" . }}
- {{ $style = print $style $style_clip_path }}
- {{ end }}
-
- {{ with ($st.Params.design.css_style | default $st.Params.advanced.css_style) }}
- {{ $style = print $style . }}
- {{ end }}
-
- {{/* Fix Hugo's ContentBaseName returning wrong file base name when page section is within a bundle. */}}
- {{ $hash_id := replace $st.File.ContentBaseName "index" (path.Base .File.Dir) }}
-
- {{ $widget := or $st.Params.widget "blank" }}
- {{ if eq $widget "custom" }}{{ $widget = "blank" }}{{ end }}{{/* Support legacy Custom widget */}}
- {{ if eq $widget "projects" }}{{ $widget = "portfolio" }}{{ end }}{{/* Support legacy Projects widget */}}
-
- {{ $widget_path := printf "widgets/%s.html" $widget }}
- {{ $widget_args := dict "root" $ "page" $st "hash_id" $hash_id }}
- {{ $css_classes := $st.Params.design.css_class | default $st.Params.advanced.css_class | default "" }}
- {{ $extra_attributes := "" }}
- {{ $use_container := true }}
-
- {{/* Special case: Slider widget. */}}
- {{ if in (slice "slider") $widget }}
- {{ $css_classes = print $css_classes " carousel slide" }}
- {{ $extra_attributes = printf "data-ride=\"carousel\" data-interval=\"%s\"" (cond ($st.Params.design.loop | default true) (string $st.Params.design.interval | default "3000") "false") }}
- {{ $use_container = false }}
- {{ end }}
-
- {{ $widget_class := printf "wg-%s" (replace (replace $widget "." "-") "_" "-") }}
-
- {{ $widget_config_file := printf "widgets/%s-config.html" $widget }}
- {{ if templates.Exists $widget_config_file }}
- {{ $cfg := partial $widget_config_file $widget_args }}
- {{ $use_container = $cfg.use_container }}
- {{end}}
-
- {{ $columns := $st.Params.design.columns | default "2" }}
- {{ $use_cols := in (slice "pages" "featured" "experience" "accomplishments" "contact" "blank" "tag_cloud" "portfolio") $widget }}
-
- {{/* Dedicated child div for bg prevents parallax 100% height issue within new CSS grid page wrapper. */}}
-
-
- {{with $bg_video}}{{end}}
-
- {{if $use_container}}{{end}}
-
- {{if $use_cols}}
-
- {{ if $st.Title }}
- {{ if eq $columns "1" }}
-
- {{ with $st.Title }}
{{ . | markdownify | emojify }}
{{ end }}
- {{ with $st.Params.subtitle }}
{{ . | markdownify | emojify }}
{{ end }}
-
- {{else}}
-
- {{ with $st.Title }}
{{ . | markdownify | emojify }}
{{ end }}
- {{ with $st.Params.subtitle }}
{{ . | markdownify | emojify }}
{{ end }}
-
- {{end}}
- {{end}}
- {{end}}
-
- {{ partial $widget_path $widget_args }}
-
- {{if $use_cols}}
-
- {{end}}
-
- {{if $use_container}}
{{end}}
-
+{{/* Load Wowchemy blocks */}}
+{{ range $index, $block := where ( $headless_bundle.Resources.ByType "page" ) ".Params.active" "!=" false }}
+ {{ partial "functions/parse_block" (dict "page" $ "block" $block) }}
{{ end }}
-
-{{/* Workaround to make Hugo's .Page.Store.Set cascade up to the parent of headless pages */}}
-{{ if $has_mermaid }}
- {{ .Page.Store.Set "has_mermaid" true }}
-{{ end }}
-
diff --git a/modules/wowchemy/layouts/partials/widgets/blank.html b/modules/wowchemy/layouts/partials/widgets/blank.html
deleted file mode 100644
index 0e8dd28e..00000000
--- a/modules/wowchemy/layouts/partials/widgets/blank.html
+++ /dev/null
@@ -1,12 +0,0 @@
-{{ $st := .page }}
-{{ $columns := $st.Params.design.columns | default "2" }}
-
-{{ if ne $columns "1" }}
-
- {{ $st.Content }}
-
-{{ else }}
-
- {{ $st.Content }}
-
-{{ end }}
diff --git a/modules/wowchemy/layouts/partials/widgets/featured.html b/modules/wowchemy/layouts/partials/widgets/featured.html
deleted file mode 100644
index a01bb93b..00000000
--- a/modules/wowchemy/layouts/partials/widgets/featured.html
+++ /dev/null
@@ -1,84 +0,0 @@
-{{/* Featured Content Widget */}}
-
-{{/* Initialise */}}
-{{ $ := .root }}
-{{ $st := .page }}
-{{ $items_type := $st.Params.content.page_type | default "post" }}
-{{ $items_count := $st.Params.content.count | default 65535 }}
-{{ $items_sort := $st.Params.content.order| default "desc" }}
-
-{{/* Query */}}
-{{ $query := where (where site.RegularPages "Type" $items_type) "Params.featured" true }}
-{{ $archive_page := site.GetPage "Section" $items_type }}
-
-{{/* Filters */}}
-{{ if $st.Params.content.filters.tag }}
- {{ $archive_page := site.GetPage (printf "tags/%s" (urlize $st.Params.content.filters.tag)) }}
- {{ $query = $query | intersect $archive_page.Pages }}
-{{ end }}
-{{ if $st.Params.content.filters.category }}
- {{ $archive_page := site.GetPage (printf "categories/%s" (urlize $st.Params.content.filters.category)) }}
- {{ $query = $query | intersect $archive_page.Pages }}
-{{ end }}
-{{ if $st.Params.content.filters.publication_type }}
- {{ $archive_page := site.GetPage (printf "publication_types/%s" $st.Params.content.filters.publication_type) }}
- {{ $query = $query | intersect $archive_page.Pages }}
-{{ end }}
-{{ if $st.Params.content.filters.author }}
- {{ $archive_page = site.GetPage (printf "authors/%s" (urlize $st.Params.content.filters.author)) }}
- {{ $query = $query | intersect $archive_page.Pages }}
-{{ end }}
-
-{{ $count := len $query }}
-
-{{/* Sort */}}
-{{ $sort_by := "Date" }}
-{{ $query = sort $query $sort_by $items_sort }}
-
-{{/* Limit */}}
-{{ $query = first $items_count $query }}
-
-{{/* Localisation */}}
-{{ $i18n := "" }}
-{{ if eq $items_type "post" }}
- {{ $i18n = "more_posts" }}
-{{ else if eq $items_type "event" }}
- {{ $i18n = "more_talks" }}
-{{ else if eq $items_type "publication" }}
- {{ $i18n = "more_publications" }}
-{{ else }}
- {{ $i18n = "more_pages" }}
-{{ end }}
-
-{{ $columns := $st.Params.design.columns | default "2" }}
-
-
-
- {{ with $st.Content }}{{ . }}{{ end }}
-
- {{ range $index, $post := $query }}
- {{ partial "functions/render_view" (dict "page" $st "item" . "view" ($st.Params.design.view | default "compact") "index" $index) }}
- {{end}}
-
- {{/* Archive link */}}
- {{ $show_archive_link := $st.Params.content.archive.enable | default (gt $count $items_count) }}
- {{ if $show_archive_link }}
-
- {{ $archive_link := "" }}
- {{ if $st.Params.content.archive.link }}
- {{ $archive_link = $st.Params.content.archive.link | relLangURL }}
- {{ else }}
- {{ $archive_link = $archive_page.RelPermalink }}
- {{ end }}
-
- {{ $archive_text := $st.Params.content.archive.text | default (i18n $i18n) | default "See all" }}
-
-
- {{ end }}
-
-