diff --git a/gatsby-browser.js b/gatsby-browser.js index 0f15d568..dfa6b6a4 100644 --- a/gatsby-browser.js +++ b/gatsby-browser.js @@ -15,6 +15,7 @@ export const onClientEntry = () => { import React from 'react'; import { Provider } from 'jotai'; + import { BeaconProvider } from './src/context/beacon-context'; export const wrapRootElement = ({ element }) => { @@ -24,3 +25,47 @@ export const wrapRootElement = ({ element }) => { ); }; + +const addScript = url => { + const script = document.createElement('script'); + script.src = url; + script.async = true; + script.type = 'text/javascript'; + script.charSet = 'utf-8'; + document.body.appendChild(script); +}; + +export const onRouteUpdate = ({ location, prevLocation }) => { + /* + 1. Check if the URL contains 'module-02' or 'module-03' + 2. If the URL has the keywords, check if SmartPy script is added or not. + 3. If SmartPy script isn't added -> add the necessary scripts. + */ + if ( + location.pathname.indexOf('module-02') != -1 || + location.pathname.indexOf('module-03') != -1 + ) { + // checking is '/smartpyio.py' script is added or not. + const scripts = Array.from(document.querySelectorAll('script')); + const srcVals = scripts + .filter(sc => typeof sc.attributes.src != 'undefined') + .map(sc => sc.attributes.src.value); + const hasSmartpy = srcVals.indexOf('/smartpyio.py'); + + if (hasSmartpy == -1) { + // adding the necessary scripts + addScript('/execute.js'); + addScript('/smartjs/smart.js'); + addScript('/smartjs/smartmljs.bc.js'); + + const script = document.createElement('script'); + script.src = '/smartpyio.py'; + script.type = 'text/python'; + document.body.appendChild(script); + if (typeof window.brython != 'undefined') { + // Initialize brython + brython({ debug: 1, indexedDB: false, pythonpath: '/' }); + } + } + } +}; diff --git a/src/assets/wealth.png b/src/assets/wealth.png deleted file mode 100644 index ddc1db6a..00000000 Binary files a/src/assets/wealth.png and /dev/null differ diff --git a/src/assets/wealth.webp b/src/assets/wealth.webp new file mode 100644 index 00000000..06deacd0 Binary files /dev/null and b/src/assets/wealth.webp differ diff --git a/src/html.js b/src/html.js index e967811e..51066825 100644 --- a/src/html.js +++ b/src/html.js @@ -24,42 +24,50 @@ export default function HTML(props) { type="text/javascript" charSet="utf-8" async + defer > + {/* + defer + > */} {props.headComponents} @@ -71,7 +79,7 @@ export default function HTML(props) { dangerouslySetInnerHTML={{ __html: props.body }} /> {props.postBodyComponents} - + {/* */} ); diff --git a/src/images/hero.webp b/src/images/hero.webp new file mode 100644 index 00000000..9fb1313e Binary files /dev/null and b/src/images/hero.webp differ diff --git a/src/pages/tezos/index.js b/src/pages/tezos/index.js index e559ed2b..ea7834a9 100644 --- a/src/pages/tezos/index.js +++ b/src/pages/tezos/index.js @@ -1,15 +1,15 @@ import React, { useState } from 'react'; -import { Link} from 'gatsby'; +import { Link } from 'gatsby'; import NavBar from '../../components/NavBar'; import Button from '../../components/Buttons'; import Footer from '../../components/Footer'; import PlayButton from '../../components/LandingPage/playbutton'; -import hero from '../../images/hero.png'; +import hero from '../../images/hero.webp'; import cryptobots from '../../images/cryptobots.png'; import earnWhileYouLearn from 'src/assets/videos/earn while you learn-anim.mp4'; import createCurrency from 'src/assets/videos/anim-create-currency.mp4'; -import FinanceIllustration from 'src/assets/wealth.png'; +import FinanceIllustration from 'src/assets/wealth.webp'; import { MdClose } from 'react-icons/md'; const FeatureGrid = ({