• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import React from 'react'
2
3const IS_STATIC = process.env.GATSBY_IS_STATIC
4
5const Scripts = () => {
6  // Workaround: Make links work on the static html site
7  if (IS_STATIC) {
8    return (
9      <script
10        dangerouslySetInnerHTML={{
11          __html: `
12          var anchors = document.querySelectorAll(".sidebar a, .documentation a")
13          Array.prototype.slice.call(anchors).map(function(el) {
14            if (el.href.match(/file:\\/\\//)) {
15              el.href = el.href + "/index.html"
16            }
17          })
18          `
19        }}
20      />
21    )
22  }
23
24  return null
25}
26
27export default Scripts
28