Skip to content

Commit

Permalink
handle "_latest" in URL during redirection (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
drewhammond authored Feb 9, 2023
1 parent c77f248 commit 4651d05
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/app/ui/templates/partials/cookbook/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h1 class="cookbook-headline">
</h1>
</div>
<div class="col-auto">
<select class="form-select form-select-sm" id="cookbook-versions-dropdown" onchange="if (this.value) window.location.href=window.location.pathname.replace('{{.cookbook.Metadata.Version}}', this.value)">
<select class="form-select form-select-sm" id="cookbook-versions-dropdown" onchange="if (this.value) changeUrl(this.value)">
<option selected value="{{ .cookbook.Metadata.Version }}">{{ .cookbook.Metadata.Version }}</option>
</select>
</div>
Expand Down Expand Up @@ -35,6 +35,11 @@ <h1 class="cookbook-headline">
selectBox.removeChild(selectBox.firstElementChild)
}
);

function changeUrl(v) {
const searchTerm = window.location.pathname.includes("/_latest/") ? "/_latest/" : '/{{.cookbook.Metadata.Version}}/'
window.location.href = window.location.pathname.replace(searchTerm, '/' + v + '/');
}
</script>
<div class="col">
<ul class="nav nav-tabs justify-content-end">
Expand Down

0 comments on commit 4651d05

Please sign in to comment.