Skip to content

Commit 4651d05

Browse files
authored
handle "_latest" in URL during redirection (#108)
1 parent c77f248 commit 4651d05

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

internal/app/ui/templates/partials/cookbook/header.html

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ <h1 class="cookbook-headline">
55
</h1>
66
</div>
77
<div class="col-auto">
8-
<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)">
8+
<select class="form-select form-select-sm" id="cookbook-versions-dropdown" onchange="if (this.value) changeUrl(this.value)">
99
<option selected value="{{ .cookbook.Metadata.Version }}">{{ .cookbook.Metadata.Version }}</option>
1010
</select>
1111
</div>
@@ -35,6 +35,11 @@ <h1 class="cookbook-headline">
3535
selectBox.removeChild(selectBox.firstElementChild)
3636
}
3737
);
38+
39+
function changeUrl(v) {
40+
const searchTerm = window.location.pathname.includes("/_latest/") ? "/_latest/" : '/{{.cookbook.Metadata.Version}}/'
41+
window.location.href = window.location.pathname.replace(searchTerm, '/' + v + '/');
42+
}
3843
</script>
3944
<div class="col">
4045
<ul class="nav nav-tabs justify-content-end">

0 commit comments

Comments
 (0)