Skip to content

Commit

Permalink
feat: use GlobalHeader in MainLayout from the theme
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jul 22, 2020
1 parent 138e73a commit 5b084cc
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/layouts/MainLayout.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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');`}
</script>
) : null}
</Helmet>
<GlobalHeader />
<GlobalHeader editUrl={editUrl} />
<MobileHeader
className={styles.hideOnDesktop}
isOpen={isMobileNavOpen}
Expand Down

0 comments on commit 5b084cc

Please sign in to comment.