Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@
<meta name="robots" content="noindex, nofollow">
{{ end -}}

{{- if eq .Kind "404" }}
<script>
(function () {
var path = window.location.pathname;
var previewPath = path.match(/^((?:\/[^/]+)?\/pr-preview\/pr-[^/]+\/)/);
var basePath = previewPath ? previewPath[1] : "/";
var base = document.createElement("base");
base.href = basePath;
document.head.insertBefore(base, document.head.firstChild);
})();
Comment on lines +18 to +25
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using var for variable declarations is an outdated practice in modern JavaScript. It is highly recommended to use const (or let if re-assignment is needed) to ensure block-scoping, prevent accidental re-declarations, and improve overall code maintainability and readability.

Suggested change
(function () {
var path = window.location.pathname;
var previewPath = path.match(/^((?:\/[^/]+)?\/pr-preview\/pr-[^/]+\/)/);
var basePath = previewPath ? previewPath[1] : "/";
var base = document.createElement("base");
base.href = basePath;
document.head.insertBefore(base, document.head.firstChild);
})();
(function () {
const path = window.location.pathname;
const previewPath = path.match(/^((?:\/[^/]+)?\/pr-preview\/pr-[^/]+\/)/);
const basePath = previewPath ? previewPath[1] : "/";
const base = document.createElement("base");
base.href = basePath;
document.head.insertBefore(base, document.head.firstChild);
})();

</script>
{{- end }}

<meta property="og:title" content="{{ .Title }}">
<meta property="og:description" content="{{ .Description }}">
<meta property="og:image" content="https://docs.layer5.io/images/layer5-gradient.webp">
Expand Down
Loading