]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
templates: use `urls.JoinPath` when handling URLs
authorXhmikosR <xhmikosr@gmail.com>
Sun, 3 Mar 2024 06:00:52 +0000 (08:00 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Wed, 6 Mar 2024 13:50:18 +0000 (15:50 +0200)
site/layouts/_default/examples.html
site/layouts/partials/docs-sidebar.html
site/layouts/partials/docs-versions.html
site/layouts/partials/header.html
site/layouts/partials/home/plugins.html
site/layouts/partials/social.html

index 82e57c1b579fb0646f9e78422b19f6fcefa41e7b..19aad368d6f58c4a40c4fda22cc76b4020a60511 100644 (file)
@@ -14,7 +14,7 @@
     <meta name="robots" content="{{ . }}">
     {{- end }}
 
-    {{- $colorModeJS := printf "/docs/%s/assets/js/color-modes.js" $.Site.Params.docs_version -}}
+    {{- $colorModeJS := urls.JoinPath "/docs" $.Site.Params.docs_version "assets/js/color-modes.js" -}}
     <script src="{{ $colorModeJS }}"></script>
 
     {{ partial "stylesheet" . }}
index e7b5576874b38baee55c62527ce50d138fe69c7a..891a47306aaf6240aa9a8a01b8f59af0d8a92c18 100644 (file)
@@ -28,7 +28,7 @@
           {{- range $doc := $group.pages -}}
             {{- $doc_slug := $doc.title | urlize -}}
             {{- $is_active := and $is_active_group (eq $page_slug $doc_slug) -}}
-            {{- $href := printf "/docs/%s/%s/%s/" $.Site.Params.docs_version $group_slug $doc_slug }}
+            {{- $href := urls.JoinPath "/docs" $.Site.Params.docs_version $group_slug $doc_slug "/" }}
             <li><a href="{{ $href }}" class="bd-links-link d-inline-block rounded{{ if $is_active }} active{{ end }}"{{ if $is_active }} aria-current="page"{{ end }}>{{ $doc.title }}</a></li>
           {{- end }}
         </ul>
index 7bb7231ef3ae43e71625acc566810613786f2d94..c465d02e900233e76e5dbc63c3162ffad0e81a40 100644 (file)
@@ -5,9 +5,9 @@
 
 {{- $versions_link := "" -}}
 {{- if and (eq .Layout "docs") (eq $page_version .Site.Params.docs_version) -}}
-  {{- $versions_link = printf "%s/%s/" $group_slug $page_slug -}}
+  {{- $versions_link = urls.JoinPath $group_slug $page_slug "/" -}}
 {{- else if (eq .Layout "single") -}}
-  {{- $versions_link = printf "%s/" $page_slug -}}
+  {{- $versions_link = urls.JoinPath $page_slug "/" -}}
 {{- end -}}
 
 {{- $added_in_51 := eq (string .Page.Params.added.version) "5.1" -}}
index ff080901e29e64df353e1530745d41d90d9e7c9b..ba58893286a06dfbcdee2251134c15a572ccd606 100644 (file)
@@ -17,7 +17,7 @@
 <meta name="robots" content="{{ . }}">
 {{- end }}
 
-{{- $colorModeJS := printf "/docs/%s/assets/js/color-modes.js" $.Site.Params.docs_version -}}
+{{- $colorModeJS := urls.JoinPath "/docs" $.Site.Params.docs_version "assets/js/color-modes.js" -}}
 <script src="{{ $colorModeJS }}"></script>
 
 {{ partial "stylesheet" . }}
index ab48d9bc601754eb66e91b0dbd0662442fc22193..e28ae1bf1f27393539ddf9d23529e5b0179f64dd 100644 (file)
@@ -50,6 +50,7 @@
       <hr class="my-4">
       <div class="row g-3">
         {{- range $plugin := .Site.Data.plugins -}}
+          {{- /* TODO we should use urls.JoinPath here too, but the links include `#` which gets escaped */ -}}
           {{- $href := printf "/docs/%s/%s" $.Site.Params.docs_version $plugin.link }}
           <div class="col-sm-6 mb-2">
             <a class="d-block pe-lg-4 text-decoration-none lh-sm" href="{{ $href }}">
index f4f556e5a82e9764e0eeb406bc9fdf0daf536601..03658ea9b1bfd588737e1f8a3196f98c8a68a2ff 100644 (file)
@@ -1,11 +1,11 @@
 {{- $pageTitle := .Title | markdownify -}}
 {{- $pageDescription := .Page.Params.description | default .Site.Params.description | markdownify -}}
-{{- $socialImagePath := printf "/docs/%s/assets" .Site.Params.docs_version -}}
+{{- $socialImagePath := urls.JoinPath "/docs" .Site.Params.docs_version "assets" -}}
 
 {{- if .Page.Params.thumbnail -}}
-  {{- $socialImagePath = path.Join $socialImagePath "img/" .Page.Params.thumbnail -}}
+  {{- $socialImagePath = urls.JoinPath $socialImagePath "img" .Page.Params.thumbnail -}}
 {{- else -}}
-  {{- $socialImagePath = path.Join $socialImagePath "brand/bootstrap-social.png" -}}
+  {{- $socialImagePath = urls.JoinPath $socialImagePath "brand/bootstrap-social.png" -}}
 {{- end -}}
 
 <meta name="twitter:card" content="summary_large_image">