diff --git a/gatsby-browser.js b/gatsby-browser.js index 993313c..d3cb7fc 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -8,47 +8,18 @@ import Modals from "./src/components/Modals" import { QueryClient, QueryClientProvider } from "@tanstack/react-query" import PrefetchData from "./src/components/PrefetchData" import PageLayout from "./src/components/PageLayout" +import { useBrowserStore } from "./src/store" // Logs when the client route changes export function onRouteUpdate({ location, prevLocation }) { console.log("[Layout] render") - console.log("[gatsby-browser]@onRouteUpdate new pathname", location.pathname) - - // let view = null - // let viewId = null - // // update zustand with search params, if any - // if (location.search) { - // const params = new URLSearchParams(location.search) - // const paramView = params.get("view") - // const paramViewId = params.get("viewId") - - // if (AvailableModalsViews.includes(paramView)) { - // console.log("[gatsby-browser]@onRouteUpdate view:", paramView) - // view = String(paramView) - // } else { - // console.log( - // "[gatsby-browser]@onRouteUpdate view not recognized, close everything:", - // paramView - // ) - // } - - // // test view id against a regex (lowercase letters and numbers, only trailing slash) - // if (paramViewId && /^[a-z0-9-]+$/.test(paramViewId)) { - // console.log("[gatsby-browser]@onRouteUpdate viewId:", paramViewId) - // viewId = String(paramViewId) - // } else { - // console.log( - // "[gatsby-browser]@onRouteUpdate viewId not recognized, close everything:", - // paramViewId - // ) - // } - // } - - // always update store with view and viewId - // useBrowserStore.setState({ - // view, - // viewId, - // }) + console.log( + "[gatsby-browser]@onRouteUpdate new pathname", + location.pathname, + "prev pathname", + prevLocation?.pathname + ) + useBrowserStore.getState().setPath(location.pathname, prevLocation?.pathname) } // Create a client diff --git a/src/components/Layout.js b/src/components/Layout.js index a90434a..e5eeb7f 100644 --- a/src/components/Layout.js +++ b/src/components/Layout.js @@ -6,11 +6,12 @@ import Wall from "./Wall" const Layout = ({ children }) => { console.log("[Layout] render") + return ( <>
-
{children}
+
{children}