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