-
Notifications
You must be signed in to change notification settings - Fork 663
/
gatsby-browser.js
53 lines (43 loc) · 1.69 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React from "react"
import { location, globalHistory } from "@reach/router"
// Import PDS Global wrapper for applying global context providers.
import { GlobalWrapper } from "@pantheon-systems/pds-toolkit-react"
import { MOBILE_MENU_BREAKPOINT } from './src/vars/responsive'
// Import PDS core styles.
import "./node_modules/@pantheon-systems/pds-toolkit-react/_dist/css/pds-core.css"
import "./node_modules/@pantheon-systems/pds-toolkit-react/_dist/css/pds-layouts.css"
import "./node_modules/@pantheon-systems/pds-toolkit-react/_dist/css/pds-components.css"
// Global styles
import "./src/styles/main.css"
import "./src/styles/custom-glyphicons.css"
import "./src/styles/pds-additions.css"
// custom typefaces
import "prismjs/themes/prism-okaidia.css"
// Code block line numbering
import "prismjs/plugins/line-numbers/prism-line-numbers.css"
// Code block shell prompt
import "./src/styles/codeBlocks.css"
// TOC generator
import "tocbot/dist/tocbot.css"
import "tocbot/dist/tocbot.min.js"
//Segment
export const onRouteUpdate = () => {
window.locations = window.locations || [document.referrer]
locations.push(window.location.href)
window.previousPath = locations[locations.length - 2]
window.analytics &&
window.analytics.page({
url: window.location.href,
referrer: window.previousPath,
title: document.title,
})
//console.log("Title: ", document.title) //For debugging
}
// Trigger resize event once rendered
export const onInitialClientRender = () => {
window.dispatchEvent(new Event("resize"))
}
// Global context providers
export const wrapRootElement = ({ element }) => {
return <GlobalWrapper mobileMenuMaxWidth={MOBILE_MENU_BREAKPOINT}>{element}</GlobalWrapper>
}