Skip to content

Commit

Permalink
chore: use graphql to get repo instead of using the constant value
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jul 22, 2020
1 parent 1c1a581 commit 752268d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/layouts/MainLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,30 @@ import cx from 'classnames';
import { Helmet } from 'react-helmet';
import { GlobalHeader } from '@newrelic/gatsby-theme-newrelic';
import { PageContext } from '../components/PageContext';
import { graphql, useStaticQuery } from 'gatsby';
import Cookies from 'js-cookie';
import Footer from '../components/Footer';
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 {
site: { siteMetadata },
} = useStaticQuery(graphql`
query {
site {
siteMetadata {
repository
}
}
}
`);
const { fileRelativePath } = useContext(PageContext);
const [cookieConsent, setCookieConsent] = useState(false);
const [isMobileNavOpen, setIsMobileNavOpen] = useState(false);
Expand All @@ -26,7 +37,7 @@ const MainLayout = ({ children }) => {
);
const editUrl = isComponentDoc
? null
: `${githubBaseUrl}/blob/main/${fileRelativePath}`;
: `${siteMetadata.repository}/blob/main/${fileRelativePath}`;

useEffect(() => {
const consentValue = Cookies.get(gdprConsentCookieName) === 'true';
Expand Down

0 comments on commit 752268d

Please sign in to comment.