diff --git a/client/src/components/ComponentB.tsx b/client/src/components/ComponentB.tsx
index bab3b44..4b077f4 100644
--- a/client/src/components/ComponentB.tsx
+++ b/client/src/components/ComponentB.tsx
@@ -9,7 +9,6 @@ import { Helmet } from "react-helmet";
import { Header, Icon, Container, Menu } from "semantic-ui-react";
import { BaseComponent } from "./BaseComponent";
import { StructuredData } from "./StructuredData";
-import * as SPAs from "../../config/spa.config";
import { getTitle, getCanonical } from "../utils/misc";
const cssNav = css({
@@ -64,7 +63,7 @@ const Navigation: React.FC = _props => {
Go back to
-
+
First SPA
= {
menu: styles["menu"],
};
+const pathArray = ["/", "/a", "/lighthouse", "/namelookup"];
+
+const getIndex = () => {
+ if (isServer()) {
+ return -1;
+ }
+ const path = window.location.pathname;
+ return pathArray.findIndex((item) => item === path);
+}
+
export const Navigation: React.FC = _props => {
+ React.useEffect(() => {
+ const idx = getIndex();
+ const menuItem = document.querySelector(`div.menu>a:nth-child(${idx + 1})`);
+ menuItem?.classList.add("active");
+ if (idx > 0) {
+ const menuItem = document.querySelector("div.menu>a:nth-child(1)");
+ menuItem?.classList.remove("active");
+ }
+ }, []); // run once upon initial rendering
+
return (