From 306e00d6b4b91b386e2429e260176038547311d6 Mon Sep 17 00:00:00 2001 From: ParzivalPavlis Date: Thu, 24 Jul 2025 12:22:31 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fixed=20one=20word=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layouts/_default/_markup/render-heading.html | 72 +++++++++++++------- 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/layouts/_default/_markup/render-heading.html b/layouts/_default/_markup/render-heading.html index 2892a4c..cadae2d 100644 --- a/layouts/_default/_markup/render-heading.html +++ b/layouts/_default/_markup/render-heading.html @@ -1,30 +1,56 @@ {{/* (C) 2023 GoodData Corporation */}} {{ $cleanText := replaceRE "\\s+" " " (htmlUnescape .Text) }} {{ $words := split $cleanText " " }} -{{ $lastWord := index $words (sub (len $words) 1)}} -{{ $withoutLast := substr $cleanText 0 (sub (len $cleanText) (add (len $lastWord) 1)) }} +{{ $wordCount := len $words }} - {{- $withoutLast | safeHTML }} - - {{- $lastWord | safeHTML -}} - {{- if in (slice 2 3 4 6) .Level }}{{" " -}} - - - {{ with resources.Get "icons/icon-anchor.svg" }} - {{ ( . | minify).Content | safeHTML }} - {{ end }} - - - {{- end -}} - + {{ if eq $wordCount 1 }} + {{/* Single word - no need to split */}} + + {{- $cleanText | safeHTML -}} + {{- if in (slice 2 3 4 6) .Level }}{{" " -}} + + + {{ with resources.Get "icons/icon-anchor.svg" }} + {{ ( . | minify).Content | safeHTML }} + {{ end }} + + + {{- end -}} + + {{ else }} + {{/* Multiple words - split to prevent line break in last word */}} + {{ $lastWord := index $words (sub $wordCount 1) }} + {{ $withoutLast := substr $cleanText 0 (sub (len $cleanText) (add (len $lastWord) 1)) }} + {{- $withoutLast | safeHTML }} + + {{- $lastWord | safeHTML -}} + {{- if in (slice 2 3 4 6) .Level }}{{" " -}} + + + {{ with resources.Get "icons/icon-anchor.svg" }} + {{ ( . | minify).Content | safeHTML }} + {{ end }} + + + {{- end -}} + + {{ end }} \ No newline at end of file