Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change does the following: * Add ability for blog posts to generate automatically * Add now.json file for deploying * Finalize content on react error boundaries * Add babel-standalone for transpiling future code to browser compat code
- Loading branch information
Showing
12 changed files
with
457 additions
and
65 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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"version": 2, | ||
"name": "mhme-blog", | ||
"builds": [ | ||
{ | ||
"src": "package.json", | ||
"use": "@now/static-build", | ||
"config": { "distDir": "public" } | ||
} | ||
] | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import React from 'react' | ||
import Helmet from 'react-helmet' | ||
import { graphql } from 'gatsby' | ||
import styled from '@emotion/styled' | ||
import Header from './header' | ||
import GlobalStyles from './GlobalStyles.js' | ||
import MDXRenderer from 'gatsby-mdx/mdx-renderer' | ||
|
||
import { transform } from '@babel/standalone' | ||
import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live' | ||
import { MDXProvider } from '@mdx-js/tag' | ||
|
||
function Code({ children, className, ...props }) { | ||
// See: https://github.com/c8r/x0/blob/5d5956517b67dcc2ea66974ca629085c2d17f9c7/src/scope.js#L47 | ||
const lang = className.replace(/^language-/, '') | ||
const type = lang.charAt(0) | ||
switch (type) { | ||
case '.': { | ||
return ( | ||
<LiveProvider | ||
code={children} | ||
{...props} | ||
className={className.replace(/\.|!/, '')} | ||
> | ||
<LiveEditor /> | ||
</LiveProvider> | ||
) | ||
} | ||
case '!': { | ||
return ( | ||
<LiveProvider | ||
noInline | ||
transformCode={code => | ||
`${ | ||
transform(code, { | ||
presets: [['stage-0', { decoratorsLegacy: true }], 'react'], | ||
}).code | ||
}render(<Example />);` | ||
} | ||
code={children} | ||
scope={{ | ||
Component: React.Component, | ||
Fragment: React.Fragment, | ||
}} | ||
{...props} | ||
className={className.replace(/\.|!/, '')} | ||
> | ||
<LivePreview /> | ||
<LiveError /> | ||
<LiveEditor /> | ||
</LiveProvider> | ||
) | ||
} | ||
default: { | ||
return ( | ||
<pre className={className} {...props}> | ||
{children} | ||
</pre> | ||
) | ||
} | ||
} | ||
} | ||
|
||
const Wrapper = styled.div({ | ||
margin: '0 auto', | ||
maxWidth: 960, | ||
padding: '0px 1.0875rem 1.45rem', | ||
paddingTop: 0, | ||
}) | ||
|
||
const Layout = ({ data: { mdx } }) => ( | ||
<> | ||
<GlobalStyles /> | ||
<> | ||
<Helmet | ||
title={mdx.frontmatter.title} | ||
meta={[ | ||
{ | ||
name: 'description', | ||
content: | ||
'A blog about technology, web development, and other things.', | ||
}, | ||
{ | ||
name: 'keywords', | ||
content: 'blog, technology, web development', | ||
}, | ||
]} | ||
> | ||
<html lang="en" /> | ||
</Helmet> | ||
<Header siteTitle={mdx.frontmatter.title} /> | ||
<MDXProvider components={{ code: Code }}> | ||
<Wrapper> | ||
<MDXRenderer>{mdx.code.body}</MDXRenderer> | ||
</Wrapper> | ||
</MDXProvider> | ||
</> | ||
</> | ||
) | ||
|
||
export default Layout | ||
|
||
export const pageQuery = graphql` | ||
query BlogPostQuery($id: String) { | ||
mdx(id: { eq: $id }) { | ||
id | ||
frontmatter { | ||
title | ||
} | ||
code { | ||
body | ||
} | ||
} | ||
} | ||
` |
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
Oops, something went wrong.