From 5d5f288bbfbbce83efaf09d9e4a926d72bb7d13d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Tue, 3 Oct 2023 01:28:24 +0200 Subject: [PATCH] theme: remove warnings with hugo --printI18nWarnings #670 --- layouts/partials/shortcodes/attachments.html | 10 ++++++++-- layouts/partials/shortcodes/badge.html | 8 +++++++- layouts/partials/shortcodes/button.html | 8 +++++++- layouts/partials/shortcodes/notice.html | 8 +++++++- layouts/partials/shortcodes/tabs.html | 18 +++++++++++++++--- 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/layouts/partials/shortcodes/attachments.html b/layouts/partials/shortcodes/attachments.html index e1b38622e6..62e6df4109 100644 --- a/layouts/partials/shortcodes/attachments.html +++ b/layouts/partials/shortcodes/attachments.html @@ -12,8 +12,14 @@ {{- if and (not $color) (eq (len $color) 0) }} {{- $style = .style | default "transparent" }} {{- end }} -{{- $title := .title | default ($style | T) | default ("Attachments-label" | T) }} -{{- $title = trim $title " " }} +{{- $title := .title }} +{{- if not $title }} + {{- if eq $style "info" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "warning" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "note" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "tip" }}{{ $title = $style | T }}{{ end }} +{{- end }} +{{- $title = trim ($title | default ("Attachments-label" | T)) " " }} {{- $icon := .icon | default "" }} {{- if and (not $icon) (eq (len $icon) 0) }} {{- $icon = "paperclip" }} diff --git a/layouts/partials/shortcodes/badge.html b/layouts/partials/shortcodes/badge.html index a6d342e79a..5aa81ab702 100644 --- a/layouts/partials/shortcodes/badge.html +++ b/layouts/partials/shortcodes/badge.html @@ -6,7 +6,13 @@ {{- $color := .color | default "" }} {{- $content := .content }} {{- $style := .style | default "default" }} -{{- $title := .title | default ($style | T) }} +{{- $title := .title }} +{{- if not $title }} + {{- if eq $style "info" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "warning" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "note" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "tip" }}{{ $title = $style | T }}{{ end }} +{{- end }} {{- $title = trim $title " " }} {{- $icon := .icon | default "" }} {{- if and (not $icon) (eq (len $icon) 0) }} diff --git a/layouts/partials/shortcodes/button.html b/layouts/partials/shortcodes/button.html index 1d1deb5eda..5956f6afc8 100644 --- a/layouts/partials/shortcodes/button.html +++ b/layouts/partials/shortcodes/button.html @@ -25,7 +25,13 @@ {{- $target = $page.Site.Params.externalLinkTarget }} {{- end }} {{- end }} -{{- $title := .title | default ($content) | default ($style | T) }} +{{- $title := .title | default ($content) }} +{{- if not $title }} + {{- if eq $style "info" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "warning" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "note" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "tip" }}{{ $title = $style | T }}{{ end }} +{{- end }} {{- $title = trim $title " " }} {{- $icon := .icon | default "" }} {{- if and (not $icon) (eq (len $icon) 0) }} diff --git a/layouts/partials/shortcodes/notice.html b/layouts/partials/shortcodes/notice.html index e863ab3ff9..d37576dcb6 100644 --- a/layouts/partials/shortcodes/notice.html +++ b/layouts/partials/shortcodes/notice.html @@ -6,7 +6,13 @@ {{- $color := .color | default "" }} {{- $content := .content }} {{- $style := .style | default "default" }} -{{- $title := .title | default ($style | T) }} +{{- $title := .title }} +{{- if not $title }} + {{- if eq $style "info" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "warning" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "note" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "tip" }}{{ $title = $style | T }}{{ end }} +{{- end }} {{- $title = trim $title " " }} {{- $icon := .icon | default "" }} {{- if and (not $icon) (eq (len $icon) 0) }} diff --git a/layouts/partials/shortcodes/tabs.html b/layouts/partials/shortcodes/tabs.html index 2e03f832dc..81bb370366 100644 --- a/layouts/partials/shortcodes/tabs.html +++ b/layouts/partials/shortcodes/tabs.html @@ -4,7 +4,7 @@ {{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'tabs' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180" $page.File.Path }} {{- end }} {{- $groupid := .groupid | default (partial "make-random-md5.hugo" $page) | plainify | anchorize }} - {{- $color := .color }} +{{- $color := .color }} {{- $style := .style }} {{- $title := .title }} {{- $icon := .icon }} @@ -17,7 +17,13 @@ {{- with $tab }} {{- $color := .color | default $color | default "" }} {{- $style := .style | default $style | default (cond (ne $color "") "filled" "initial") }} - {{- $title := .title | default ($style | T) }} + {{- $title := .title }} + {{- if not $title }} + {{- if eq $style "info" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "warning" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "note" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "tip" }}{{ $title = $style | T }}{{ end }} + {{- end }} {{- $title = trim $title " " }} {{- $icon := .icon | default "" }} {{- if and (not $icon) (eq (len $icon) 0) }} @@ -42,7 +48,13 @@ {{- end }} {{- $color = .color | default "" }} {{- $style = .style | default (cond (ne $color "") "filled" "initial") }} -{{- $title = .title | default ($style | T) }} +{{- $title = .title }} +{{- if not $title }} + {{- if eq $style "info" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "warning" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "note" }}{{ $title = $style | T }}{{ end }} + {{- if eq $style "tip" }}{{ $title = $style | T }}{{ end }} +{{- end }} {{- $title = trim $title " " }} {{- $icon = .icon | default "" }} {{- if and (not $icon) (eq (len $icon) 0) }}