-
Notifications
You must be signed in to change notification settings - Fork 5
/
gatsby-browser.js
96 lines (85 loc) · 2.73 KB
/
gatsby-browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import React from 'react';
import PageLayout from './src/layouts/PageLayout';
import { MDXProvider } from '@mdx-js/react';
import Highlight, { defaultProps } from 'prism-react-renderer';
import { Helmet } from 'react-helmet';
import styled from 'styled-components';
import './src/scss/main.scss';
import '@fortawesome/fontawesome-free/css/all.css';
const Pre = styled.pre`
text-align: left;
margin: 1em 0;
padding: 1rem;
overflow: auto;
font-family: 'Consolas';
font-size: 1.6rem;
line-height: 1.5;
`;
const Line = styled.div`
display: table-row;
`;
const LineNo = styled.span`
display: table-cell;
text-align: right;
padding-right: 1em;
user-select: none;
opacity: 0.5;
`;
const LineContent = styled.span`
display: table-cell;
`;
const components = {
pre: props => {
const className = props.children.props.className || "";
const matches = className.match(/language-(?<lang>.*)/);
return (
<Highlight
{...defaultProps}
code={props.children.props.children.trim()}
language={
matches && matches.groups && matches.groups.lang
? matches.groups.lang
: ""
}
>
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<Pre className={className} style={style}>
{tokens.map((line, i) => (
<Line key={i} {...getLineProps({ line, key: i })}>
<LineNo>{i + 1}</LineNo>
<LineContent>
{line.map((token, key) => (
<span key={key} {...getTokenProps({ token, key })} />
))}
</LineContent>
</Line>
))}
</Pre>
)}
</Highlight>
)
},
a: props => <a target="_blank" {...props} />
}
export const wrapRootElement = ({ element }) => {
return (
<>
<Helmet
title="Framer Motion Playground"
meta={[
{
name: 'description',
content: 'Interactive blog with Framer Motion Tutorials.'
}
]}
/>
<MDXProvider components={components}>
{element}
</MDXProvider>
</>
)
}
export const wrapPageElement = ({ element, props }) => {
return <PageLayout {...props}>{element}</PageLayout>
}
export const shouldUpdateScroll = () => false;