From b5eeaaa2e390e0ab35bd4782174081002f2a46f2 Mon Sep 17 00:00:00 2001 From: Charlie Egan Date: Wed, 17 Jan 2024 17:27:08 +0000 Subject: [PATCH] docs: Fix issue in versioning docs for search https://github.com/open-policy-agent/opa/pull/6526 contained two errors, that I can see. First, it used `Permalink` rather than `RelPermalink`, this contains the host and scheme on build and so the older versions of pages were all getting version set to the latest. Even if that had worked, the setting of version was incorrect and set a locally scoped var instead of the variable for the whole file. Signed-off-by: Charlie Egan --- docs/website/layouts/partials/meta.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/website/layouts/partials/meta.html b/docs/website/layouts/partials/meta.html index 34dda51f29..e0450b5758 100644 --- a/docs/website/layouts/partials/meta.html +++ b/docs/website/layouts/partials/meta.html @@ -1,3 +1,7 @@ +{{ $version := "latest" }} +{{ if strings.HasPrefix .RelPermalink "/docs/" }} + {{ $version = index (split .File.Path "/") 1 -}} +{{ end -}} {{ $isHome := .IsHome }} {{ $isDoc := eq .Section "docs" }} {{ $title := cond $isHome site.Title .Title }} @@ -5,14 +9,10 @@ {{ $pageType := cond $isHome "website" "article" }} {{ $imageUrl := "/img/logos/opa-horizontal-color.png" | absURL }} {{ $twitter := site.Params.social.twitter }} -{{ $version := "latest" }} -{{ if strings.HasPrefix .Permalink "/docs/" }} -{{ $version := index (split .File.Path "/") 1 }} -{{ end }} -{{ $page := trim .RelPermalink "/" }} -{{ $releases := site.Data.releases }} -{{ $latest := index $releases 1 }} -{{ $isLatest := or (eq $version $latest) (eq $version "latest") }} +{{ $page := trim .RelPermalink "/" }} +{{ $releases := site.Data.releases }} +{{ $latest := index $releases 1 }} +{{ $isLatest := or (eq $version $latest) (eq $version "latest") }}