From 5b084ccc1ada85e72b33c99544966fbf8ce0bcf5 Mon Sep 17 00:00:00 2001 From: Jerel Miller Date: Wed, 22 Jul 2020 10:43:32 -0700 Subject: [PATCH] feat: use GlobalHeader in MainLayout from the theme --- src/layouts/MainLayout.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/layouts/MainLayout.js b/src/layouts/MainLayout.js index e16dd0b2d..2898e931b 100644 --- a/src/layouts/MainLayout.js +++ b/src/layouts/MainLayout.js @@ -1,23 +1,32 @@ -import React, { useState, useEffect } from 'react'; +import React, { useContext, useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import cx from 'classnames'; import { Helmet } from 'react-helmet'; +import { GlobalHeader } from '@newrelic/gatsby-theme-newrelic'; +import { PageContext } from '../components/PageContext'; import Cookies from 'js-cookie'; import Footer from '../components/Footer'; -import GlobalHeader from '../components/GlobalHeader'; import MobileHeader from '../components/MobileHeader'; import Sidebar from '../components/Sidebar'; import CookieApprovalDialog from '../components/CookieApprovalDialog'; import styles from './MainLayout.module.scss'; +import { githubBaseUrl } from '../data/constants'; import '../components/styles.scss'; const gaTrackingId = 'UA-3047412-33'; const gdprConsentCookieName = 'newrelic-gdpr-consent'; const MainLayout = ({ children }) => { + const { fileRelativePath } = useContext(PageContext); const [cookieConsent, setCookieConsent] = useState(false); const [isMobileNavOpen, setIsMobileNavOpen] = useState(false); + const isComponentDoc = fileRelativePath.includes( + 'src/markdown-pages/components' + ); + const editUrl = isComponentDoc + ? null + : `${githubBaseUrl}/blob/main/${fileRelativePath}`; useEffect(() => { const consentValue = Cookies.get(gdprConsentCookieName) === 'true'; @@ -33,14 +42,14 @@ const MainLayout = ({ children }) => { (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); - + ga('create', '${gaTrackingId}', 'auto'); ga('set', 'anonymizeIp', true); ga('send', 'pageview');`} ) : null} - +