-
Notifications
You must be signed in to change notification settings - Fork 2
/
gatsby-browser.js
38 lines (32 loc) · 937 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
/* eslint-disable */
require('prismjs/themes/prism-tomorrow.css')
/**
* Trust All Scripts
*
* This is a dirty little script for iterating over script tags
* of your Ghost posts and adding them to the document head.
*
* This works for any script that then injects content into the page
* via ids/classnames etc.
*
*/
var trustAllScripts = function () {
var scriptNodes = document.querySelectorAll('.load-external-scripts script')
for (var i = 0; i < scriptNodes.length; i += 1) {
var node = scriptNodes[i]
var s = document.createElement('script')
s.type = node.type || 'text/javascript'
if (node.attributes.src) {
s.src = node.attributes.src.value
} else {
s.innerHTML = node.innerHTML
}
document.getElementsByTagName('head')[0].appendChild(s)
}
}
exports.onRouteUpdate = function () {
trustAllScripts()
setTimeout(() => {
dispatchEvent(new Event('load'))
}, 1000)
}