-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closses: #16
- Loading branch information
Marvin Heilemann
committed
Feb 9, 2020
1 parent
b902632
commit 86b3a74
Showing
3 changed files
with
39 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,44 @@ | ||
import React, { useContext } from 'react' | ||
import React from 'react' | ||
import { Helmet } from 'react-helmet-async' | ||
import { MDXProvider } from '@mdx-js/react' | ||
import { globalHistory } from '@reach/router' | ||
import { scroller } from 'react-scroll' | ||
|
||
import { ThemeContext } from '../provider/theme' | ||
import Header from './Header' | ||
import Footer from './Footer' | ||
import ScrollToTop from '../components/ScrollToTop' | ||
import mdxElements from '../components/MDXElements' | ||
|
||
const Index = ({ children }) => { | ||
const { theme } = useContext(ThemeContext) | ||
export default class Index extends React.Component { | ||
static contextType = ThemeContext | ||
|
||
return ( | ||
<> | ||
<Helmet htmlAttributes={{ theme }} /> | ||
<Header></Header> | ||
<MDXProvider components={mdxElements}> | ||
<main role="main" id="main"> | ||
{children} | ||
</main> | ||
</MDXProvider> | ||
<Footer></Footer> | ||
<ScrollToTop /> | ||
</> | ||
) | ||
} | ||
componentDidMount() { | ||
const hash = globalHistory.location.hash | ||
if (hash) { | ||
setTimeout(() => { | ||
scroller.scrollTo(hash.substr(1), { | ||
offset: -30, | ||
duration: 200, | ||
smooth: true, | ||
}) | ||
}, 300) | ||
} | ||
} | ||
|
||
export default Index | ||
render() { | ||
return ( | ||
<> | ||
<Helmet htmlAttributes={{ theme: this.context.theme }} /> | ||
<Header></Header> | ||
<MDXProvider components={mdxElements}> | ||
<main role="main" id="main"> | ||
{this.props.children} | ||
</main> | ||
</MDXProvider> | ||
<Footer></Footer> | ||
<ScrollToTop /> | ||
</> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters