diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 10373adb8..856c873cd 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -48,6 +48,6 @@ {{ partial "footer.html" . }} - {{ partial "javascript.html" }} + {{ partial "javascript.html" . }} diff --git a/layouts/partials/javascript.html b/layouts/partials/javascript.html index 70d2ca1d1..bdfee5c10 100644 --- a/layouts/partials/javascript.html +++ b/layouts/partials/javascript.html @@ -1,6 +1,29 @@ {{ $alpineJsVersion := site.Params.alpine_js_version }} +{{ $versions := site.Params.versions }} +{{ $latest := (index $versions 0).harborversion }} +{{ $version := "" }} +{{ with .File }} + {{ $pathParts := split .Path "/" }} + {{ if gt (len $pathParts) 1 }} + {{ $version = index $pathParts 1 }} + {{ end }} +{{ end }} + +{{/* + Check if $version is a valid doc version (e.g. starts with a digit or is 'edge' or 'latest'). + If not, or if we are not in the docs section, use the latest harbor version. +*/}} +{{ $isDocVersion := false }} +{{ if and (eq .Section "docs") (ne $version "") }} + {{ if or (findRE `^[0-9]` $version) (eq $version "edge") (eq $version "latest") }} + {{ $isDocVersion = true }} + {{ end }} +{{ end }} + +{{ $docVersion := cond $isDocVersion $version $latest }} + {{/* Algolia DocSearch JS */}} diff --git a/layouts/partials/meta.html b/layouts/partials/meta.html index 4c60c94f5..9f36eae3a 100644 --- a/layouts/partials/meta.html +++ b/layouts/partials/meta.html @@ -15,6 +15,10 @@ {{ if $isDoc }} +{{ $version := "" }}{{ with .File }}{{ $version = index (split .Path "/") 1 }}{{ end }} +{{ if or (findRE `^[0-9]` $version) (eq $version "edge") (eq $version "latest") }} + +{{ end }} {{ end }}