Skip to content

Instantly share code, notes, and snippets.

@tonyspiro
Last active October 10, 2017 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyspiro/cc5b1d57cec0734ce3df37b1432cad38 to your computer and use it in GitHub Desktop.
Save tonyspiro/cc5b1d57cec0734ce3df37b1432cad38 to your computer and use it in GitHub Desktop.
import React from 'react'
import Cosmic from 'cosmicjs'
const config = {
bucket: {
slug: 'next-app'
}
}
export default class extends React.Component {
static async getInitialProps({ req }) {
return new Promise((resolve, reject) => {
Cosmic.getObject(config, { slug: 'home' }, (err, res) => {
return resolve(res.object)
})
})
}
render() {
return (
<div>
<div style={{ paddingTop: 100, backgroundImage: `url(${this.props.metadata.hero.imgix_url})`, backgroundSize: 'cover', width: '100%', height: 500 }}>
<h1 style={{ color: '#fff', textAlign: 'center' }}>{this.props.metadata.headline}</h1>
</div>
<div style={{ textAlign: 'center' }} dangerouslySetInnerHTML={{ __html: this.props.content }}></div>
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment