-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v2] Update Emotion + PrismJS example (#5720)
* Add required packages + upgrade their versions * Refactor layout component to v2 * Migrate from custom html.js to react-helmet * Add references to README * Fix typo + remove semi * Fix typo * Fix lint errors + remove unused console.log * Fix mixed up blog post content * Show proper page titles * remove word * remove word
- Loading branch information
1 parent
0b66c94
commit 1572240
Showing
13 changed files
with
168 additions
and
178 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
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,28 +1,34 @@ | ||
{ | ||
"name": "using-emotion-prismjs", | ||
"description": "Gatsby example using emotion and PrismJS Gatsby plugin for code snippet highlighting", | ||
"description": "Gatsby example using Emotion and PrismJS Gatsby plugin for code snippet highlighting", | ||
"main": "n/a", | ||
"scripts": { | ||
"develop": "gatsby develop", | ||
"build": "gatsby build" | ||
}, | ||
"dependencies": { | ||
"emotion": "^8.0.2-8", | ||
"emotion-server": "^8.0.2-8", | ||
"gatsby": "latest", | ||
"gatsby-plugin-emotion": "latest", | ||
"gatsby-plugin-google-analytics": "^1.0.1", | ||
"gatsby-plugin-offline": "^1.0.1", | ||
"gatsby-plugin-typography": "^1.7.10", | ||
"gatsby-remark-prismjs": "^1.2.8", | ||
"gatsby-source-filesystem": "^1.5.5", | ||
"gatsby-transformer-remark": "^1.7.17", | ||
"emotion": "^9.1.3", | ||
"emotion-server": "^9.1.3", | ||
"gatsby": "next", | ||
"gatsby-plugin-emotion": "next", | ||
"gatsby-plugin-google-analytics": "next", | ||
"gatsby-plugin-offline": "next", | ||
"gatsby-plugin-react-helmet": "next", | ||
"gatsby-plugin-typography": "next", | ||
"gatsby-remark-prismjs": "next", | ||
"gatsby-source-filesystem": "next", | ||
"gatsby-transformer-remark": "next", | ||
"lodash": "^4.17.4", | ||
"prismjs": "^1.14.0", | ||
"prop-types": "^15.6.0", | ||
"react-emotion": "^8.0.2-8", | ||
"typography": "^0.16.6", | ||
"react": "^16.4.0", | ||
"react-dom": "^16.4.0", | ||
"react-emotion": "^9.1.3", | ||
"react-helmet": "^5.2.0", | ||
"react-typography": "^0.16.13", | ||
"typography": "^0.16.17", | ||
"typography-theme-bootstrap": "^0.16.7" | ||
}, | ||
"author": "Andrew Wyatt <andrewrwyatt@gmail.com>", | ||
"license": "MIT" | ||
} | ||
} |
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,73 @@ | ||
import React from "react" | ||
import { Link, StaticQuery } from "gatsby" | ||
import PropTypes from "prop-types" | ||
import { css } from "react-emotion" | ||
import Helmet from "react-helmet" | ||
|
||
import { rhythm } from "../utils/typography" | ||
import "../prism-styles" | ||
|
||
const indexContainer = css` | ||
max-width: ${rhythm(30)}; | ||
margin: ${rhythm(1)} auto 0; | ||
padding: ${rhythm(1)}; | ||
` | ||
|
||
const link = css` | ||
box-shadow: none; | ||
text-decoration: none; | ||
color: inherit; | ||
` | ||
|
||
class Layout extends React.Component { | ||
render() { | ||
const HeadingTag = this.props.isIndex ? `h1` : `h3` | ||
const { siteTitle, pageTitle } = this.props | ||
const title = pageTitle ? `${pageTitle} — ${siteTitle}` : `${siteTitle}` | ||
|
||
return ( | ||
<> | ||
<Helmet> | ||
<title>{title}</title> | ||
<meta | ||
name="description" | ||
content="Gatsby example site using Emotion and PrismJS" | ||
/> | ||
<meta name="referrer" content="origin" /> | ||
</Helmet> | ||
<div className={indexContainer}> | ||
<HeadingTag> | ||
<Link className={link} to={`/`}> | ||
Using Gatsby with Emotion and PrismJS | ||
</Link> | ||
</HeadingTag> | ||
{this.props.children} | ||
</div> | ||
</> | ||
) | ||
} | ||
} | ||
|
||
Layout.propTypes = { | ||
siteTitle: PropTypes.string.isRequired, | ||
pageTitle: PropTypes.string, | ||
isIndex: PropTypes.bool, | ||
children: PropTypes.node.isRequired, | ||
} | ||
|
||
export default props => ( | ||
<StaticQuery | ||
query={graphql` | ||
query LayoutQuery { | ||
site { | ||
siteMetadata { | ||
title | ||
} | ||
} | ||
} | ||
`} | ||
render={data => ( | ||
<Layout siteTitle={data.site.siteMetadata.title} {...props} /> | ||
)} | ||
/> | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.