-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-browser.js
31 lines (26 loc) · 1.06 KB
/
gatsby-browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require("./src/style/custom.less");
require("./src/style/animation.less");
// typography
require("katex/dist/katex.min.css");
require("./src/style/typography.less");
require("./src/style/typography-extend.less");
require("./src/style/highlight.css");
const React = require("react");
const Layout = require("./src/components/Layout").default;
exports.onPreRouteUpdate = () => {
// const unsafeWindow = typeof window === "undefined" ? {} : window;
// console.log("[Gatsby]", "onPreRouteUpdate", unsafeWindow.location?.pathname);
};
exports.onRouteUpdate = () => {
const unsafeWindow = typeof window === "undefined" ? {} : window;
const { setMobileOpen } = unsafeWindow;
if (setMobileOpen) {
setMobileOpen(false); // 切换页面时自动关闭Mobile端打开的drawer
// console.log("[hack]", "close mobile drawer");
}
// console.log("[Gatsby]", "onRouteUpdate", unsafeWindow.location?.pathname);
};
// 避免在页面内切换时重新挂载Layout组件
exports.wrapPageElement = ({ element, props }) => {
return React.createElement(Layout, props, element);
};