-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgatsby-browser.js
32 lines (29 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
32
/**
* Implement Gatsby's Browser APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/browser-apis/
*/
import React from 'react'
import qs from 'querystring'
import Layout from './src/components/layout/layout'
import adapter from 'webrtc-adapter' // for camera api compatability
// Removes token from url if it exists.
export const onClientEntry = () => {
const parsedQueryString = qs.parse(window.location.search.slice(1))
if (parsedQueryString.access !== undefined) {
// Tokens are now saved when the user logs in from the axios post request.
// Kept for reference.
//window.localStorage.setItem('token', parsedQueryString.access)
// update url in the address bar without refreshing the page.
window.history.replaceState(
window.history.state,
window.history.pageTitle,
window.location.pathname
)
}
}
export const wrapPageElement = ({ element, props }) => (
// props provide same data to Layout as Page element will get
// including location, data, etc - you don't need to pass it
<Layout {...props}>{element}</Layout>
)