Skip to content
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ colors:
light: "#FF5788"
dark: "#FB326E"

banner:
Copy link
Member

Choose a reason for hiding this comment

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

We can't use this function for the banner because if we ever want to create a banner (eg for kubecon or taloscon event) it would hide the version warning banner.

content: "You are viewing an older version of the docs. See the [latest version](https://docs.siderolabs.com/talos/latest)."
dismissible: false

favicon: "/images/favicon.svg"

contextual:
Expand Down
52 changes: 52 additions & 0 deletions public/banner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
(function () {
function shouldCheckPath() {
const path = window.location.pathname;

return (
path.startsWith("/omni/") ||
path.startsWith("/kubernetes-guides/") ||
path.startsWith("/talos/v1.12/")
);
}

function deleteVersionBannerIfNeeded() {
if (!shouldCheckPath()) return;

const banner = document.getElementById("banner");
if (!banner) return;

const isVersionBanner =
banner.textContent &&
banner.textContent.includes(
"You are viewing an older version of the docs."
);

if (isVersionBanner) {
banner.remove();
}
}

deleteVersionBannerIfNeeded();

// Run after hydration
window.addEventListener("load", deleteVersionBannerIfNeeded);

// Handle SPA navigation (Next.js)
const pushState = history.pushState;
history.pushState = function () {
pushState.apply(this, arguments);
setTimeout(deleteVersionBannerIfNeeded, 0);
};

window.addEventListener("popstate", () => {
setTimeout(deleteVersionBannerIfNeeded, 0);
});

// Watch for React re-mounting the banner
const observer = new MutationObserver(deleteVersionBannerIfNeeded);
observer.observe(document.body, {
childList: true,
subtree: true,
});
})();

4 changes: 4 additions & 0 deletions public/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"dark": "#FB326E"
},
"favicon": "/images/favicon.svg",
"banner": {
"content": "You are viewing an older version of the docs. See the [latest version](https://docs.siderolabs.com/talos/latest).",
"dismissible": false
},
"contextual": {
"options": [
"copy",
Expand Down
Loading