-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-browser.js
38 lines (32 loc) · 1004 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
/**
* Implement Gatsby's Browser APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/browser-apis/
*
* Note: There is an equivalent hook in Gatsby’s SSR API. It is recommended to use both APIs together.
*/
import React from "react"
import Layout from "./src/components/layout"
import "@fontsource/titillium-web"
import PropTypes from "prop-types"
export const shouldUpdateScroll = ({ routerProps: { location } }) => {
if (location.hash) {
return false
}
return true
}
// Logs when the client route changes
export const onRouteUpdate = ({ location, prevLocation }) => {
console.log("new pathname", location.pathname)
console.log("old pathname", prevLocation ? prevLocation.pathname : null)
}
export const wrapRootElement = ({ element }) => {
return <>{element}</>
}
wrapRootElement.propTypes = {
element: PropTypes.element,
}
// Wraps every page in a component
export const wrapPageElement = ({ element, props }) => {
return <Layout {...props}>{element}</Layout>
}