Greetings!
What is my question?
I am having diffuclty trying to integrate my jquery scripts into my Gatsby website.
It used to be a HTML5 Up website theme.
Everything else works inside it, the fonts, css etc. Just not the jquery scripts so I cannot get the following elements displaying.
The side bar which is referenced in the code as ‘navPanel’
Or the massively icon which is referenced in the code as ‘header’
I will get 404 with all the jquery files as shown here.
Steps to recreate?
Go to where ever you store your local projects and run this.
git clone https://github.com/LayersOfAbstraction/joshuafluke.github.io.git
cd joshuafluke.github.io/gatgsby-companion-site
git fetch
git checkout gatsby-integration-v2
git reset --hard origin/gatsby-integration-v2
npm install
gatsby develop
If you cannot see the gatsby-integration-v2 branch just get it from here.
What have I done to solve the problem?
I went here to this tutorial and installed react Helmet like this.
npm install react-helmet gatsby-plugin-react-helmet
I wraped all the scripts in the helmet tag like this in my index.js file:
import { Link } from "gatsby"
import React from "react"
import pic1 from "../images/pic01.jpg"
import pic2 from "../images/pic02.jpg"
import pic3 from "../images/pic03.jpg"
import "../assets/css/font-awesome.min.css"
import "../assets/css/main.css"
import "../assets/css/noscript.css"
import { Helmet } from "react-helmet"
import { withPrefix } from "gatsby"
export default function Home() {
return(
<>
{/* ....Omitted code.*/}
<Helmet>
<script src={withPrefix('../assets/js/jquery.min.js')} />
<script src={withPrefix('../assets/js/jquery.scrollex.min.js')} />
<script src={withPrefix('../assets/js/jquery.scrolly.min.js')} />
<script src={withPrefix('../assets/js/browser.min.js')} />
<script src={withPrefix('../assets/js/breakpoints.min.js')} />
<script src={withPrefix('../assets/js/util.js')} />
<script src={withPrefix('../assets/js/main.js')} />
</Helmet>
</>
);
}