From 0b624e2eff953153f13db8ad70ceddec3bf81cac Mon Sep 17 00:00:00 2001 From: George Cushen Date: Mon, 24 Oct 2022 23:05:17 +0100 Subject: [PATCH] refactor: move old widgets to v1/ dir Prevent conflicts with new v2 landing page block system See #2049 --- .../layouts/partials/blocks/about.avatar.html | 2 +- .../layouts/partials/blocks/markdown.html | 4 +- .../partials/blocks/v1/about.avatar.html | 91 +++++++++++++++++++ .../partials/blocks/{ => v1}/about.html | 0 .../blocks/{ => v1}/accomplishments.html | 0 .../partials/blocks/{ => v1}/collection.html | 0 .../partials/blocks/{ => v1}/contact.html | 0 .../partials/blocks/{ => v1}/experience.html | 0 .../partials/blocks/{ => v1}/features.html | 0 .../partials/blocks/{ => v1}/hero.html | 0 .../layouts/partials/blocks/v1/markdown.html | 18 ++++ .../partials/blocks/{ => v1}/people.html | 0 .../partials/blocks/{ => v1}/portfolio.html | 0 .../partials/blocks/{ => v1}/slider.html | 0 .../partials/blocks/{ => v1}/tag_cloud.html | 0 .../{parse_block.html => parse_block_v1.html} | 2 +- .../layouts/partials/widget_page.html | 2 +- 17 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 modules/wowchemy/layouts/partials/blocks/v1/about.avatar.html rename modules/wowchemy/layouts/partials/blocks/{ => v1}/about.html (100%) rename modules/wowchemy/layouts/partials/blocks/{ => v1}/accomplishments.html (100%) rename modules/wowchemy/layouts/partials/blocks/{ => v1}/collection.html (100%) rename modules/wowchemy/layouts/partials/blocks/{ => v1}/contact.html (100%) rename modules/wowchemy/layouts/partials/blocks/{ => v1}/experience.html (100%) rename modules/wowchemy/layouts/partials/blocks/{ => v1}/features.html (100%) rename modules/wowchemy/layouts/partials/blocks/{ => v1}/hero.html (100%) create mode 100644 modules/wowchemy/layouts/partials/blocks/v1/markdown.html rename modules/wowchemy/layouts/partials/blocks/{ => v1}/people.html (100%) rename modules/wowchemy/layouts/partials/blocks/{ => v1}/portfolio.html (100%) rename modules/wowchemy/layouts/partials/blocks/{ => v1}/slider.html (100%) rename modules/wowchemy/layouts/partials/blocks/{ => v1}/tag_cloud.html (100%) rename modules/wowchemy/layouts/partials/functions/{parse_block.html => parse_block_v1.html} (99%) diff --git a/modules/wowchemy/layouts/partials/blocks/about.avatar.html b/modules/wowchemy/layouts/partials/blocks/about.avatar.html index 741da9d0..c72010a3 100644 --- a/modules/wowchemy/layouts/partials/blocks/about.avatar.html +++ b/modules/wowchemy/layouts/partials/blocks/about.avatar.html @@ -10,7 +10,7 @@ {{ if .author }} {{ $author = .author }} {{ else }} - {{ $author = $block.Params.author | default $block.content.username }} + {{ $author = $block.content.username }} {{end}} {{ $person_page_path := (printf "/authors/%s" $author) }} diff --git a/modules/wowchemy/layouts/partials/blocks/markdown.html b/modules/wowchemy/layouts/partials/blocks/markdown.html index cc0a6de3..36dc506e 100644 --- a/modules/wowchemy/layouts/partials/blocks/markdown.html +++ b/modules/wowchemy/layouts/partials/blocks/markdown.html @@ -5,8 +5,8 @@ {{/* Initialise */}} {{ $page := .wcPage }} {{ $block := .wcBlock }} -{{ $columns := $block.Params.design.columns | default $block.design.columns | default "2" }} -{{ $text := $block.Content | default ($block.content.text | emojify | markdownify) }} +{{ $columns := $block.design.columns | default "2" }} +{{ $text := $block.content.text | emojify | markdownify }} {{ if ne $columns "1" }}
diff --git a/modules/wowchemy/layouts/partials/blocks/v1/about.avatar.html b/modules/wowchemy/layouts/partials/blocks/v1/about.avatar.html new file mode 100644 index 00000000..59a22dd7 --- /dev/null +++ b/modules/wowchemy/layouts/partials/blocks/v1/about.avatar.html @@ -0,0 +1,91 @@ +{{/* Wowchemy Blocks: About - avatar variation */}} +{{/* Documentation: https://wowchemy.com/blocks/ */}} +{{/* License: https://github.com/wowchemy/wowchemy-hugo-themes/blob/main/LICENSE.md */}} + +{{/* Initialise */}} +{{ $page := .wcPage }} +{{ $block := .wcBlock }} + +{{ $author := "" }} +{{ if .author }} + {{ $author = .author }} +{{ else }} + {{ $author = $block.Params.author }} +{{end}} + +{{ $person_page_path := (printf "/authors/%s" $author) }} +{{ $person_page := site.GetPage $person_page_path }} +{{ if not $person_page }} + {{ errorf "Could not find an author page at `%s`. Please check the value of `author` in your About widget and create an associated author page if one does not already exist. See https://wowchemy.com/docs/page-builder/#about " $person_page_path }} +{{end}} +{{ $person := $person_page.Params }} +{{ $avatar := ($person_page.Resources.ByType "image").GetMatch "*avatar*" }} +{{ $avatar_shape := site.Params.features.avatar.shape | default "circle" }} + +
+ + {{ if $avatar }} +
+ {{ $avatar_image := $avatar.Fill "150x150 Center" }} + {{$person_page.Title}} + {{with $person.status.icon}}{{.|emojify}}{{end}} +
+ {{ end }} + +
+ +

+ {{- if $person.name_pronunciation -}} + + {{ $person_page.Title }} + {{ $person.name_pronunciation }} + + {{- else -}} + {{- $person_page.Title -}} + {{- end -}} +

+ + {{ with $person.role }}

{{ . | markdownify | emojify }}

{{ end }} + + {{ range $person.organizations }} +

+ {{ with .url }}{{ end }} + {{ .name }} + {{ if .url }}{{ end }} +

+ {{ end }} +
+ + + + {{ with $block.Content }} +
+ {{ . }} +
+ {{ end }} + +
diff --git a/modules/wowchemy/layouts/partials/blocks/about.html b/modules/wowchemy/layouts/partials/blocks/v1/about.html similarity index 100% rename from modules/wowchemy/layouts/partials/blocks/about.html rename to modules/wowchemy/layouts/partials/blocks/v1/about.html diff --git a/modules/wowchemy/layouts/partials/blocks/accomplishments.html b/modules/wowchemy/layouts/partials/blocks/v1/accomplishments.html similarity index 100% rename from modules/wowchemy/layouts/partials/blocks/accomplishments.html rename to modules/wowchemy/layouts/partials/blocks/v1/accomplishments.html diff --git a/modules/wowchemy/layouts/partials/blocks/collection.html b/modules/wowchemy/layouts/partials/blocks/v1/collection.html similarity index 100% rename from modules/wowchemy/layouts/partials/blocks/collection.html rename to modules/wowchemy/layouts/partials/blocks/v1/collection.html diff --git a/modules/wowchemy/layouts/partials/blocks/contact.html b/modules/wowchemy/layouts/partials/blocks/v1/contact.html similarity index 100% rename from modules/wowchemy/layouts/partials/blocks/contact.html rename to modules/wowchemy/layouts/partials/blocks/v1/contact.html diff --git a/modules/wowchemy/layouts/partials/blocks/experience.html b/modules/wowchemy/layouts/partials/blocks/v1/experience.html similarity index 100% rename from modules/wowchemy/layouts/partials/blocks/experience.html rename to modules/wowchemy/layouts/partials/blocks/v1/experience.html diff --git a/modules/wowchemy/layouts/partials/blocks/features.html b/modules/wowchemy/layouts/partials/blocks/v1/features.html similarity index 100% rename from modules/wowchemy/layouts/partials/blocks/features.html rename to modules/wowchemy/layouts/partials/blocks/v1/features.html diff --git a/modules/wowchemy/layouts/partials/blocks/hero.html b/modules/wowchemy/layouts/partials/blocks/v1/hero.html similarity index 100% rename from modules/wowchemy/layouts/partials/blocks/hero.html rename to modules/wowchemy/layouts/partials/blocks/v1/hero.html diff --git a/modules/wowchemy/layouts/partials/blocks/v1/markdown.html b/modules/wowchemy/layouts/partials/blocks/v1/markdown.html new file mode 100644 index 00000000..0e92ab48 --- /dev/null +++ b/modules/wowchemy/layouts/partials/blocks/v1/markdown.html @@ -0,0 +1,18 @@ +{{/* Wowchemy Blocks: Markdown */}} +{{/* Documentation: https://wowchemy.com/blocks/ */}} +{{/* License: https://github.com/wowchemy/wowchemy-hugo-themes/blob/main/LICENSE.md */}} + +{{/* Initialise */}} +{{ $page := .wcPage }} +{{ $block := .wcBlock }} +{{ $columns := $block.Params.design.columns | default "2" }} + +{{ if ne $columns "1" }} +
+ {{ $block.Content }} +
+{{ else }} +
+ {{ $block.Content }} +
+{{ end }} diff --git a/modules/wowchemy/layouts/partials/blocks/people.html b/modules/wowchemy/layouts/partials/blocks/v1/people.html similarity index 100% rename from modules/wowchemy/layouts/partials/blocks/people.html rename to modules/wowchemy/layouts/partials/blocks/v1/people.html diff --git a/modules/wowchemy/layouts/partials/blocks/portfolio.html b/modules/wowchemy/layouts/partials/blocks/v1/portfolio.html similarity index 100% rename from modules/wowchemy/layouts/partials/blocks/portfolio.html rename to modules/wowchemy/layouts/partials/blocks/v1/portfolio.html diff --git a/modules/wowchemy/layouts/partials/blocks/slider.html b/modules/wowchemy/layouts/partials/blocks/v1/slider.html similarity index 100% rename from modules/wowchemy/layouts/partials/blocks/slider.html rename to modules/wowchemy/layouts/partials/blocks/v1/slider.html diff --git a/modules/wowchemy/layouts/partials/blocks/tag_cloud.html b/modules/wowchemy/layouts/partials/blocks/v1/tag_cloud.html similarity index 100% rename from modules/wowchemy/layouts/partials/blocks/tag_cloud.html rename to modules/wowchemy/layouts/partials/blocks/v1/tag_cloud.html diff --git a/modules/wowchemy/layouts/partials/functions/parse_block.html b/modules/wowchemy/layouts/partials/functions/parse_block_v1.html similarity index 99% rename from modules/wowchemy/layouts/partials/functions/parse_block.html rename to modules/wowchemy/layouts/partials/functions/parse_block_v1.html index 19d027a8..4abfe7f0 100644 --- a/modules/wowchemy/layouts/partials/functions/parse_block.html +++ b/modules/wowchemy/layouts/partials/functions/parse_block_v1.html @@ -10,7 +10,7 @@ {{ 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 }} +{{ $widget_path := printf "blocks/v1/%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 }} diff --git a/modules/wowchemy/layouts/partials/widget_page.html b/modules/wowchemy/layouts/partials/widget_page.html index 64bcb7f9..1ac5c76b 100644 --- a/modules/wowchemy/layouts/partials/widget_page.html +++ b/modules/wowchemy/layouts/partials/widget_page.html @@ -28,5 +28,5 @@ {{/* Load Wowchemy blocks */}} {{ range $index, $block := where ( $headless_bundle.Resources.ByType "page" ) ".Params.active" "!=" false }} - {{ partial "functions/parse_block" (dict "page" $ "block" $block) }} + {{ partial "functions/parse_block_v1" (dict "page" $ "block" $block) }} {{ end }}