Skip to content

Commit

Permalink
update 404 nav issue
Browse files Browse the repository at this point in the history
  • Loading branch information
reigj1 committed Nov 25, 2024
1 parent d442df6 commit 9a6be9c
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions src/theme/NotFound.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,51 @@ export default function NotFound() {

useEffect(() => {
trackEvent("404", window.location.pathname);

setIsClient(true);

if (ExecutionEnvironment.canUseDOM) {
// style tags
const style = document.createElement("style");
style.textContent = " ";
style.textContent = `
.subnav {
display: none !important;
}
.tw-title-navigation {
color: #3b00b9 !important;
}
.navbar__search-button {
color: #3b00b9 !important;
background-color: #f8f9fa !important;
}
`;
document.head.appendChild(style);
requestAnimationFrame(() => document.head.removeChild(style));

// Cleanup function
return () => {
// Reset subnav
const subnav = document.querySelector(".subnav");
if (subnav) {
subnav.style.display = "";
}

// Reset nav
const titleNav = document.querySelector(".tw-title-navigation");
if (titleNav) {
titleNav.style.color = "";
}

// Reset search
const searchButton = document.querySelector(".navbar__search-button");
if (searchButton) {
searchButton.style.color = "";
searchButton.style.backgroundColor = "";
}

// Remove the style tag
if (style.parentNode) {
document.head.removeChild(style);
}
};
}
}, []);

Expand Down

0 comments on commit 9a6be9c

Please sign in to comment.