From 6550b1171f00c4c4e0b5d4b5e7483cc474ed6143 Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Wed, 2 Jul 2025 14:51:57 -0700 Subject: [PATCH 1/2] Callouts: Fixed partially styled call-outs --- exampleSite/_banners/test-product-intro.md | 6 +++++ exampleSite/content/test-product/_index.md | 5 ++++ layouts/partials/callout.html | 27 +++++++++++----------- layouts/shortcodes/banner.html | 3 ++- layouts/shortcodes/call-out.html | 15 ++---------- 5 files changed, 28 insertions(+), 28 deletions(-) create mode 100644 exampleSite/_banners/test-product-intro.md diff --git a/exampleSite/_banners/test-product-intro.md b/exampleSite/_banners/test-product-intro.md new file mode 100644 index 0000000..cc6c467 --- /dev/null +++ b/exampleSite/_banners/test-product-intro.md @@ -0,0 +1,6 @@ +{{}} +
+ This product on our example site is under development and changes are being added frequently. +
+ Please reach out to #friends-of-the-docs on Slack to ask questions. +{{
}} \ No newline at end of file diff --git a/exampleSite/content/test-product/_index.md b/exampleSite/content/test-product/_index.md index df11ae2..0a681ba 100644 --- a/exampleSite/content/test-product/_index.md +++ b/exampleSite/content/test-product/_index.md @@ -3,6 +3,11 @@ description: Test pages for nginx-hugo-theme title: Test pages weight: 100 nd-landing-page: true +cascade: + nd-banner: + enabled: true + start-date: 2025-01-01 + md: /_banners/test-product-intro.md --- {{}} {{}} diff --git a/layouts/partials/callout.html b/layouts/partials/callout.html index 616bfe0..11a842a 100644 --- a/layouts/partials/callout.html +++ b/layouts/partials/callout.html @@ -34,6 +34,7 @@ {{/* Render a different block, if "loud" callouts are used */}} +{{ $type := (index (split $class " ") 0) | strings.FirstUpper }} {{ $specialTitles := slice "Caution" "Warning" "Deprecated" "Important" }} {{ $specialTitleIcons := dict "Caution" "alert-triangle" @@ -41,24 +42,22 @@ "Deprecated" "alert-octagon" "Important" "arrow-right-circle" }} -{{ $icon := index $specialTitleIcons $title | default "" }} +{{ $icon := index $specialTitleIcons $type | default "" }} -{{ $isSpecialTitle := in $specialTitles $title }} +{{ $isSpecialTitle := in $specialTitles $type }} {{ if $isSpecialTitle }} - {{/* Loud callouts */}} +{{/* Loud callouts */}} + {{ else }} diff --git a/layouts/shortcodes/banner.html b/layouts/shortcodes/banner.html index 5240248..374e53d 100644 --- a/layouts/shortcodes/banner.html +++ b/layouts/shortcodes/banner.html @@ -1,9 +1,10 @@ {{- $type := .Get 0 | default (.Get "type") | default "" -}} {{- $title := .Get 1 | default (.Get "title") | default "" -}} {{ partial "callout.html" (dict - "class" $type + "class" (printf "%s %s" $type "call-out") "title" $title "icon" "fa-solid fa-triangle-exclamation" "inline" true + "type" ($type | strings.FirstUpper) "content" .Inner ) }} \ No newline at end of file diff --git a/layouts/shortcodes/call-out.html b/layouts/shortcodes/call-out.html index fe0b387..397dc1c 100644 --- a/layouts/shortcodes/call-out.html +++ b/layouts/shortcodes/call-out.html @@ -25,21 +25,10 @@ {{ warnf "The '' Shortcode parameter 'inline' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $inlineParam}} {{ end }} -{{ $inline := eq $inlineParam "true" }} - -{{ $sideOption := "side-callout" }} -{{ $inlineOption := "inline-callout" }} - -{{ if $inline }} - {{ $class = printf "%s %s" $class $inlineOption }} -{{ else }} - {{ $class = printf "%s %s" $class $sideOption }} -{{ end }} - {{ partial "callout.html" (dict - "class" $class + "class" (printf "%s %s" $class "call-out") "title" $title "icon" $icon - "inline" $inline + "inline" $inlineParam "content" .Inner ) }} \ No newline at end of file From a1da30d9560c386a868af5926c6cd42665b59a5a Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Wed, 2 Jul 2025 15:03:50 -0700 Subject: [PATCH 2/2] Callouts: Refactored inline param to be sideline param instead --- .../test-product/call-out/call-out-param-types.md | 10 +++++----- .../content/test-product/call-out/call-out-side.md | 2 +- layouts/partials/callout.html | 10 +++++----- layouts/shortcodes/banner.html | 2 +- layouts/shortcodes/before-you-begin.html | 2 +- layouts/shortcodes/call-out.html | 14 +++++++------- layouts/shortcodes/caution.html | 2 +- layouts/shortcodes/deprecated.html | 2 +- layouts/shortcodes/important.html | 2 +- layouts/shortcodes/note.html | 2 +- layouts/shortcodes/see-also.html | 2 +- layouts/shortcodes/tip.html | 2 +- layouts/shortcodes/warning.html | 2 +- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/exampleSite/content/test-product/call-out/call-out-param-types.md b/exampleSite/content/test-product/call-out/call-out-param-types.md index 86e694c..1433d83 100644 --- a/exampleSite/content/test-product/call-out/call-out-param-types.md +++ b/exampleSite/content/test-product/call-out/call-out-param-types.md @@ -13,20 +13,20 @@ The callout shortcode aims to support both, but **not** in the same shortcode in ## The two callouts below using **unnamed** params {{}} -This callout uses the icon check-circle. **This should be an inline callout.** +This callout uses the icon check-circle. **This should be an sideline callout.** {{}} {{}} -This callout uses the icon check-circle. **This should be an sideline callout.** +This callout uses the icon check-circle. **This should be an inline callout.** {{}} ## The two callouts below using **named** params This should work exactly the same as the two callouts above -{{}} -This callout uses the icon check-circle. **This should be an inline callout.** +{{}} +This callout uses the icon check-circle. **This should be an sideline callout.** {{}} -{{}} +{{}} This callout uses the icon check-circle. **This should be an sideline callout.** {{}} diff --git a/exampleSite/content/test-product/call-out/call-out-side.md b/exampleSite/content/test-product/call-out/call-out-side.md index 497d318..b3b41ef 100644 --- a/exampleSite/content/test-product/call-out/call-out-side.md +++ b/exampleSite/content/test-product/call-out/call-out-side.md @@ -46,6 +46,6 @@ This assumes the callout text is shorter than the text in the callout. If the text in the paragraph is shorter than the callout, it's likely the content needs to be re-written. -{{}} +{{}} I am some call out text. Look at me go! {{}} \ No newline at end of file diff --git a/layouts/partials/callout.html b/layouts/partials/callout.html index 11a842a..aab0433 100644 --- a/layouts/partials/callout.html +++ b/layouts/partials/callout.html @@ -2,18 +2,18 @@ {{ $class := .class | default "" }} {{ $title := .title | default "" }} {{ $icon := .icon | default "" }} -{{ $inlineParam := .inline | default "false" | lower }} +{{ $sidelineParam := .sideline | default "false" | lower }} -{{ if not (in (slice "true" "false") $inlineParam) }} - {{ errorf "Invalid parameter 'inline'='%s' passed to blockquote partial from '%s'. Allowed values: true, false" $inlineParam .Page.Path }} +{{ if not (in (slice "true" "false") $sidelineParam) }} + {{ errorf "Invalid parameter 'sideline'='%s' passed to blockquote partial from '%s'. Allowed values: true, false" $sidelineParam .Page.Path }} {{ end }} {{/* Figure out inline/side and set class accordingly */}} -{{ $inline := eq $inlineParam "true" }} +{{ $sideline := eq $sidelineParam "true" }} {{ $sideOption := "side-callout" }} {{ $inlineOption := "inline-callout" }} -{{ if $inline }} +{{ if $sideline }} {{ $class = printf "%s %s" $class $sideOption }} {{ else }} {{ $class = printf "%s %s" $class $inlineOption }} diff --git a/layouts/shortcodes/banner.html b/layouts/shortcodes/banner.html index 374e53d..3d4b50d 100644 --- a/layouts/shortcodes/banner.html +++ b/layouts/shortcodes/banner.html @@ -4,7 +4,7 @@ "class" (printf "%s %s" $type "call-out") "title" $title "icon" "fa-solid fa-triangle-exclamation" - "inline" true + "sideline" true "type" ($type | strings.FirstUpper) "content" .Inner ) }} \ No newline at end of file diff --git a/layouts/shortcodes/before-you-begin.html b/layouts/shortcodes/before-you-begin.html index e3c14fb..a69efa0 100644 --- a/layouts/shortcodes/before-you-begin.html +++ b/layouts/shortcodes/before-you-begin.html @@ -2,7 +2,7 @@ "class" "tip" "title" "Before you begin:" "icon" "" - "inline" "false" + "sideline" "false" "content" .Inner ) }} {{ warnf "'' is being deprecated. Use generic 'call-out' shortcode instead."}} \ No newline at end of file diff --git a/layouts/shortcodes/call-out.html b/layouts/shortcodes/call-out.html index 397dc1c..d25266e 100644 --- a/layouts/shortcodes/call-out.html +++ b/layouts/shortcodes/call-out.html @@ -1,13 +1,13 @@ {{/* Usage: -{{}} -This callout uses the icon check-circle. **This should be an inline callout.** +{{}} +This callout uses the icon check-circle. **This should be an sideline callout.** {{}} Backwards compatibility usage: {{}} -This callout uses the icon check-circle. **This should be an inline callout.** +This callout uses the icon check-circle. **This should be an sideline callout.** {{}} Depends on `callout.html` partial. @@ -19,16 +19,16 @@ {{ $icon := .Get 2 | default (.Get "icon") | default "" }} {{/* Handle different versions of booleans */}} -{{ $inlineParam := (.Get 3) | default (.Get "inline") | default "false" | lower }} +{{ $sidelineParam := (.Get 3) | default (.Get "sideline") | default "false" | lower }} {{- /* Validate the parameter strictly */ -}} -{{ if not (in (slice "true" "false") $inlineParam) }} - {{ warnf "The '' Shortcode parameter 'inline' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $inlineParam}} +{{ if not (in (slice "true" "false") $sidelineParam) }} + {{ warnf "The '' Shortcode parameter 'sideline' must be 'true' or 'false', but got: '%s'. This will now default to 'false'" $sidelineParam}} {{ end }} {{ partial "callout.html" (dict "class" (printf "%s %s" $class "call-out") "title" $title "icon" $icon - "inline" $inlineParam + "sideline" $sidelineParam "content" .Inner ) }} \ No newline at end of file diff --git a/layouts/shortcodes/caution.html b/layouts/shortcodes/caution.html index 866fba3..ffbbd12 100644 --- a/layouts/shortcodes/caution.html +++ b/layouts/shortcodes/caution.html @@ -2,6 +2,6 @@ "class" "caution call-out" "title" "Caution" "icon" "" -"inline" "false" +"sideline" "false" "content" .Inner ) }} \ No newline at end of file diff --git a/layouts/shortcodes/deprecated.html b/layouts/shortcodes/deprecated.html index 512092d..f4b5b6e 100644 --- a/layouts/shortcodes/deprecated.html +++ b/layouts/shortcodes/deprecated.html @@ -2,6 +2,6 @@ "class" "warning call-out" "title" "Deprecated" "icon" "" -"inline" "false" +"sideline" "false" "content" .Inner ) }} \ No newline at end of file diff --git a/layouts/shortcodes/important.html b/layouts/shortcodes/important.html index ee48cd7..b65fb3c 100644 --- a/layouts/shortcodes/important.html +++ b/layouts/shortcodes/important.html @@ -2,6 +2,6 @@ "class" "important call-out" "title" "Important" "icon" "" -"inline" "false" +"sideline" "false" "content" .Inner ) }} \ No newline at end of file diff --git a/layouts/shortcodes/note.html b/layouts/shortcodes/note.html index 08f1209..53a7123 100644 --- a/layouts/shortcodes/note.html +++ b/layouts/shortcodes/note.html @@ -2,7 +2,7 @@ "class" "note" "title" "Note:" "icon" "" -"inline" "false" +"sideline" "false" "content" .Inner ) }} {{ warnf "'' is being deprecated. Use generic 'call-out' shortcode instead."}} \ No newline at end of file diff --git a/layouts/shortcodes/see-also.html b/layouts/shortcodes/see-also.html index 505f94d..259381e 100644 --- a/layouts/shortcodes/see-also.html +++ b/layouts/shortcodes/see-also.html @@ -2,7 +2,7 @@ "class" "tip" "title" "See Also:" "icon" "" -"inline" "false" +"sideline" "false" "content" .Inner ) }} {{ warnf "'' is being deprecated. Use generic 'call-out' shortcode instead."}} \ No newline at end of file diff --git a/layouts/shortcodes/tip.html b/layouts/shortcodes/tip.html index a0659e9..d1034d4 100644 --- a/layouts/shortcodes/tip.html +++ b/layouts/shortcodes/tip.html @@ -2,7 +2,7 @@ "class" "tip" "title" "Tip:" "icon" "" -"inline" "false" +"sideline" "false" "content" .Inner ) }} {{ warnf "'' is being deprecated. Use generic 'call-out' shortcode instead."}} \ No newline at end of file diff --git a/layouts/shortcodes/warning.html b/layouts/shortcodes/warning.html index ca08971..5be3aff 100644 --- a/layouts/shortcodes/warning.html +++ b/layouts/shortcodes/warning.html @@ -2,6 +2,6 @@ "class" "warning call-out" "title" "Warning" "icon" "" -"inline" "false" +"sideline" "false" "content" .Inner ) }} \ No newline at end of file