forked from geeksblabla/geeksblabla.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-browser.js
38 lines (33 loc) · 836 Bytes
/
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
32
33
34
35
36
37
38
import React from "react"
import { ModeProvider } from "./src/components/Mode/ModeContext"
import { ThemeProvider } from "./src/components/Theme/ThemeContext"
import "./src/styles/common.scss"
// set Mode Provider
export const wrapRootElement = ({ element }) => (
<ThemeProvider>
<ModeProvider>{element}</ModeProvider>
</ThemeProvider>
)
// Load Lato typeface
require("typeface-lato")
const w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0)
// in gastby-browser.js
export const shouldUpdateScroll = ({
prevRouterProps: {
location: { pathname: prevPathName },
},
routerProps: {
location: { pathname },
},
}) => {
if (w < 860) {
return true
}
if (
prevPathName.indexOf("blabla") !== -1 &&
pathname.indexOf("blabla") !== -1
) {
return false
}
return true
}