2018-05-06 23:22:42 +02:00
|
|
|
import React, { Component } from 'react'
|
2018-06-23 00:54:45 +02:00
|
|
|
import PropTypes from 'prop-types'
|
2018-06-22 18:54:29 +02:00
|
|
|
import { Link } from 'gatsby'
|
2018-05-06 23:22:42 +02:00
|
|
|
import giphyAPI from 'giphy-js-sdk-core'
|
2018-07-14 19:22:38 +02:00
|
|
|
import Button from '../components/atoms/Button'
|
2018-10-17 01:24:49 +02:00
|
|
|
import styles from './404.module.scss'
|
2018-04-25 23:37:23 +02:00
|
|
|
|
2018-05-06 23:22:42 +02:00
|
|
|
// Famous last words:
|
|
|
|
// "It's just the 404 page so why not expose the dev API key"
|
|
|
|
const giphyClient = giphyAPI('LfXRwufRyt6PK414G2kKJBv3L8NdnxyR')
|
|
|
|
const tag = 'fail-cat'
|
|
|
|
|
2018-09-06 14:28:01 +02:00
|
|
|
export default class NotFound extends Component {
|
|
|
|
state = { gif: '' }
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
location: PropTypes.object
|
2018-05-06 23:22:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.getRandomGif()
|
|
|
|
}
|
|
|
|
|
2018-10-17 02:03:45 +02:00
|
|
|
async getRandomGif() {
|
|
|
|
try {
|
|
|
|
let response = await giphyClient.random('gifs', { tag })
|
|
|
|
const gif = response.data.images.original.mp4
|
|
|
|
this.setState({ gif })
|
|
|
|
} catch (error) {
|
|
|
|
return error
|
|
|
|
}
|
2018-05-06 23:22:42 +02:00
|
|
|
}
|
|
|
|
|
2018-09-06 11:34:50 +02:00
|
|
|
handleClick = e => {
|
2018-05-06 23:22:42 +02:00
|
|
|
e.preventDefault()
|
|
|
|
this.getRandomGif()
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2018-10-17 01:24:49 +02:00
|
|
|
<article className={styles.content}>
|
2018-09-14 20:22:57 +02:00
|
|
|
<h1>Shenanigans, page not found.</h1>
|
|
|
|
<p>
|
|
|
|
You might want to check the url, or{' '}
|
2018-10-17 02:03:45 +02:00
|
|
|
<Link to={'/'}>go back to the homepage</Link>. Or just check out some{' '}
|
|
|
|
{tag} gifs, entirely your choice.
|
2018-09-14 20:22:57 +02:00
|
|
|
</p>
|
|
|
|
|
|
|
|
<video className="gif" src={this.state.gif} autoPlay loop />
|
|
|
|
|
|
|
|
<div>
|
2018-10-17 02:03:45 +02:00
|
|
|
<Button
|
|
|
|
onClick={this.handleClick}
|
|
|
|
>{`Get another '${tag}' gif`}</Button>
|
2018-09-14 20:22:57 +02:00
|
|
|
</div>
|
2018-10-17 01:24:49 +02:00
|
|
|
</article>
|
2018-05-06 23:22:42 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|