0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-03-13 13:29:25 +01:00

templates: use urls.JoinPath when handling URLs

This commit is contained in:
XhmikosR 2024-03-03 08:00:52 +02:00
parent 192b7f785e
commit b3bca581f1
6 changed files with 9 additions and 8 deletions

View 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" . }}

View 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>

View 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" -}}

View 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" . }}

View 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 }}">

View 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">