]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Fix docs-versions.html (#39738)
authorXhmikosR <xhmikosr@gmail.com>
Tue, 5 Mar 2024 18:24:46 +0000 (20:24 +0200)
committerGitHub <noreply@github.com>
Tue, 5 Mar 2024 18:24:46 +0000 (20:24 +0200)
Cast to string when comparing the versions, otherwise we were comparing numbers with strings.

Also, move checks to variables.

Fixes 404 errors in the version picker.

site/layouts/partials/docs-versions.html

index d09c6551a86b407c84db3b08e06937262581769b..637add3967c4223b521ef72f1c33ac6da5f03494 100644 (file)
   {{- $versions_link = printf "%s/" $page_slug -}}
 {{- end }}
 
+{{- $added_in_51 := eq (string .Page.Params.added) "5.1" -}}
+{{- $added_in_52 := eq (string .Page.Params.added) "5.2" -}}
+{{- $added_in_53 := eq (string .Page.Params.added) "5.3" -}}
+
 <li class="nav-item dropdown">
   <button type="button" class="btn btn-link nav-link py-2 px-0 px-lg-2 dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" data-bs-display="static">
     <span class="d-lg-none" aria-hidden="true">Bootstrap</span><span class="visually-hidden">Bootstrap&nbsp;</span> v{{ .Site.Params.docs_version }} <span class="visually-hidden">(switch to other versions)</span>
       </a>
     </li>
     <li>
-      {{- if (eq .Page.Params.added "5.3") }}
+      {{- if ($added_in_53) }}
         <div class="dropdown-item disabled">v5.2.3</div>
       {{- else }}
         <a class="dropdown-item" href="https://getbootstrap.com/docs/5.2/{{ $versions_link }}">v5.2.3</a>
       {{- end }}
     </li>
     <li>
-      {{- if or (eq .Page.Params.added "5.2") (eq .Page.Params.added "5.3") }}
+      {{- if (or $added_in_52 $added_in_53) }}
         <div class="dropdown-item disabled">v5.1.3</div>
       {{- else }}
         <a class="dropdown-item" href="https://getbootstrap.com/docs/5.1/{{ $versions_link }}">v5.1.3</a>
       {{- end }}
     </li>
     <li>
-      {{- if or (eq .Page.Params.added "5.1") (eq .Page.Params.added "5.2") (eq .Page.Params.added "5.3") }}
+      {{- if (or $added_in_51 $added_in_52 $added_in_53) }}
         <div class="dropdown-item disabled">v5.0.2</div>
       {{- else }}
         <a class="dropdown-item" href="https://getbootstrap.com/docs/5.0/{{ $versions_link }}">v5.0.2</a>