aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <[email protected]>2024-03-03 08:00:52 +0200
committerXhmikosR <[email protected]>2024-03-06 15:50:18 +0200
commitb3bca581f12601455bce520d2d8935f982c51bf7 (patch)
tree8964aac0544ee6901bec90f16590cadb96b1df7f
parent192b7f785ee91dd8dde62bc37a8c6fa02cdba194 (diff)
downloadbootstrap-b3bca581f12601455bce520d2d8935f982c51bf7.tar.xz
bootstrap-b3bca581f12601455bce520d2d8935f982c51bf7.zip
templates: use `urls.JoinPath` when handling URLs
-rw-r--r--site/layouts/_default/examples.html2
-rw-r--r--site/layouts/partials/docs-sidebar.html2
-rw-r--r--site/layouts/partials/docs-versions.html4
-rw-r--r--site/layouts/partials/header.html2
-rw-r--r--site/layouts/partials/home/plugins.html1
-rw-r--r--site/layouts/partials/social.html6
6 files changed, 9 insertions, 8 deletions
diff --git a/site/layouts/_default/examples.html b/site/layouts/_default/examples.html
index 82e57c1b5..19aad368d 100644
--- a/site/layouts/_default/examples.html
+++ b/site/layouts/_default/examples.html
@@ -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" . }}
diff --git a/site/layouts/partials/docs-sidebar.html b/site/layouts/partials/docs-sidebar.html
index e7b557687..891a47306 100644
--- a/site/layouts/partials/docs-sidebar.html
+++ b/site/layouts/partials/docs-sidebar.html
@@ -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>
diff --git a/site/layouts/partials/docs-versions.html b/site/layouts/partials/docs-versions.html
index 7bb7231ef..c465d02e9 100644
--- a/site/layouts/partials/docs-versions.html
+++ b/site/layouts/partials/docs-versions.html
@@ -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" -}}
diff --git a/site/layouts/partials/header.html b/site/layouts/partials/header.html
index ff080901e..ba5889328 100644
--- a/site/layouts/partials/header.html
+++ b/site/layouts/partials/header.html
@@ -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" . }}
diff --git a/site/layouts/partials/home/plugins.html b/site/layouts/partials/home/plugins.html
index ab48d9bc6..e28ae1bf1 100644
--- a/site/layouts/partials/home/plugins.html
+++ b/site/layouts/partials/home/plugins.html
@@ -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 }}">
diff --git a/site/layouts/partials/social.html b/site/layouts/partials/social.html
index f4f556e5a..03658ea9b 100644
--- a/site/layouts/partials/social.html
+++ b/site/layouts/partials/social.html
@@ -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">