From e4e1871454bcafa70dfb3a02276bdf09ff2a9563 Mon Sep 17 00:00:00 2001 From: Elinorre Date: Sat, 25 Jan 2020 13:48:14 +0300 Subject: [PATCH] removed ssr --- src/components/dataforge/header.js | 16 +++++++++------- src/components/dataforge/sidebar.js | 18 ++++++++++-------- src/components/header.js | 10 ++++++---- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/components/dataforge/header.js b/src/components/dataforge/header.js index 1b7b319..8091c9e 100644 --- a/src/components/dataforge/header.js +++ b/src/components/dataforge/header.js @@ -1,19 +1,21 @@ import React from "react" import {Link} from "gatsby" -import logo from "../../images/dataforge/df_logo.png" +import { globalHistory as history } from '@reach/router' +import logo from "../../images/dataforge/df_logo.png" import "../../styles/dataforge/header.css" import "../../styles/bootstrap.min.css" import {Navbar, Nav} from "react-bootstrap" const Header = () => { let curActive = [' ', ' ', ' ', ' ', ' ', ' ']; - if (document.location.pathname === '/dataforge/news'){curActive[0] = 'active';} - if (document.location.pathname === '/dataforge/docs'){curActive[1] = 'active';} - if (document.location.pathname === '/dataforge/modules'){curActive[2] = 'active';} - if (document.location.pathname === '/dataforge/releases'){curActive[3] = 'active';} - if (document.location.pathname === '/dataforge/apps'){curActive[4] = 'active';} - if (document.location.pathname === '/dataforge/misc'){curActive[5] = 'active';} + const { location } = history; + if (location.pathname === '/dataforge/news'){curActive[0] = 'active';} + if (location.pathname === '/dataforge/docs'){curActive[1] = 'active';} + if (location.pathname === '/dataforge/modules'){curActive[2] = 'active';} + if (location.pathname === '/dataforge/releases'){curActive[3] = 'active';} + if (location.pathname === '/dataforge/apps'){curActive[4] = 'active';} + if (location.pathname === '/dataforge/misc'){curActive[5] = 'active';} return(
diff --git a/src/components/dataforge/sidebar.js b/src/components/dataforge/sidebar.js index 8ea4169..f782bad 100644 --- a/src/components/dataforge/sidebar.js +++ b/src/components/dataforge/sidebar.js @@ -1,17 +1,19 @@ import React from "react" import { Link } from "gatsby" +import { globalHistory as history } from '@reach/router' import { push as Menu } from "react-burger-menu" const SideBar = ( props ) => { let curActive = [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']; - if (document.location.pathname === '/dataforge/docs/'){curActive[0] = 'active';} - if (document.location.pathname === '/dataforge/docs/meta'){curActive[1] = 'active';} - if (document.location.pathname === '/dataforge/docs/framework'){curActive[2] = 'active';} - if (document.location.pathname === '/dataforge/docs/data_flow'){curActive[3] = 'active';} - if (document.location.pathname === '/dataforge/docs/envelopes'){curActive[4] = 'active';} - if (document.location.pathname === '/dataforge/docs/storage'){curActive[5] = 'active';} - if (document.location.pathname === '/dataforge/docs/control'){curActive[6] = 'active';} - if (document.location.pathname === '/dataforge/docs/extensions'){curActive[7] = 'active';} + var { location } = history; + if (location.pathname === '/dataforge/docs/'){curActive[0] = 'active';} + if (location.pathname === '/dataforge/docs/meta'){curActive[1] = 'active';} + if (location.pathname === '/dataforge/docs/framework'){curActive[2] = 'active';} + if (location.pathname === '/dataforge/docs/data_flow'){curActive[3] = 'active';} + if (location.pathname === '/dataforge/docs/envelopes'){curActive[4] = 'active';} + if (location.pathname === '/dataforge/docs/storage'){curActive[5] = 'active';} + if (location.pathname === '/dataforge/docs/control'){curActive[6] = 'active';} + if (location.pathname === '/dataforge/docs/extensions'){curActive[7] = 'active';} return( 1 - How to read this documentation diff --git a/src/components/header.js b/src/components/header.js index 2b58457..8845f84 100644 --- a/src/components/header.js +++ b/src/components/header.js @@ -5,12 +5,14 @@ import logo from "../images/index/logo_white.png" import "bootstrap/dist/css/bootstrap.css" import "../styles/header.css" import {Navbar, Nav} from "react-bootstrap" +import { globalHistory as history } from '@reach/router' -const Header = () => { +const Header = ( ) => { 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';} + const { location } = history; + if (location.pathname=== '/about'){curActive[0] = 'active';} + if (location.pathname=== '/projects/physics' || location.pathname === '/projects/education' || location.pathname === '/projects/math' || location.pathname === '/projects/software'){curActive[1] = 'active';} + if (location.pathname=== '/partners'){curActive[2] = 'active';} return(