site/gatsby-ssr.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-01-15 17:45:50 +03:00
import React from "react";
export function onRenderBody(
{ setHeadComponents, setPostBodyComponents }
) {
setHeadComponents([
<script
key="head1"
type="text/javascript"
2020-01-22 20:20:52 +03:00
src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
2020-01-15 17:45:50 +03:00
/>,
<script
2020-01-22 20:20:52 +03:00
key="head2"
2020-01-15 17:45:50 +03:00
type="text/javascript"
2020-01-22 20:20:52 +03:00
stc="https://code.jquery.com/jquery-3.4.1.js"
2020-01-15 17:45:50 +03:00
/>,
<script
2020-01-22 20:20:52 +03:00
key="postbody1"
2020-01-15 17:45:50 +03:00
type="text/javascript"
2020-01-22 20:20:52 +03:00
src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js"
2020-01-15 17:45:50 +03:00
/>,
<script
2020-01-22 20:20:52 +03:00
key="activePage"
dangerouslySetInnerHTML={{
__html: `
let curActive = [' ', ' ', ' '];
if (document.location.pathname === '/about'){curActive[0] = 'active';}
if (document.location.pathname === '/projects/physics' || document.location.pathname === '/projects/education' || document.location.pathname === '/projects/math' || document.location.pathname === '/projects/software'){curActive[1] = 'active';}
if (document.location.pathname === '/partners'){curActive[2] = 'active';}
2020-01-15 17:45:50 +03:00
`
2020-01-22 20:20:52 +03:00
}}
2020-01-15 17:45:50 +03:00
/>
]);
2020-01-22 20:20:52 +03:00
setPostBodyComponents([
2020-01-15 17:45:50 +03:00
]);
}