-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
index.js
102 lines (98 loc) · 2.96 KB
/
index.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
97
98
99
100
101
102
import React from "react"
import Link from "gatsby-link"
import Img from "gatsby-image"
import { rhythm } from "../utils/typography"
class IndexComponent extends React.Component {
render() {
return (
<div>
<Img
css={{ top: 0, left: 0, right: 0, zIndex: -1 }}
style={{ position: `absolute` }}
responsiveSizes={this.props.data.imageSharp.responsiveSizes}
/>
<div
css={{
background: `white`,
zIndex: 1,
padding: rhythm(2),
borderRadius: rhythm(1 / 2),
marginTop: rhythm(3),
}}
>
<h1 css={{ marginTop: 0 }}>Gatsby Image</h1>
<p>
<a href="https://www.gatsbyjs.org/packages/gatsby-image/">
gatsby-image
</a>{` `}
is the official Image component for use in building Gatsby websites.
It provides the fastest, most optimized image loading performance
possible for Gatsby (and other React) websites.
</p>
<p>
The component requires <em>no configuration</em> when used within
Gatsby. All image processing is done within Gatsby and official
plugins.
</p>
<p>
<a href="https://github.com/gatsbyjs/gatsby/blob/master/examples/using-gatsby-image/">
See the site source
</a>{` `}
on how to start using gatsby-image on your site. Full documentation
coming soon.
</p>
<h2>Demo pages</h2>
<ul>
<li>
<Link to="/blur-up/">Blur Up</Link>
</li>
<li>
<Link to="/background-color/">Background color</Link>
</li>
</ul>
<h2>Out of the box it:</h2>
<ul>
<li>
Loads the optimal size of image for each device size and screen
resolution
</li>
<li>
Holds the image position while loading so your page doesn't jump
around as images load
</li>
<li>
Uses the "blur-up" effect i.e. it loads a tiny version of the
image to show while the full image is loading
</li>
<li>
Lazy loads images which reduces bandwidth and speeds the initial
load time
</li>
</ul>
<h2>Documentation</h2>
<p>
<a href="https://www.gatsbyjs.org/packages/gatsby-image/">
See the project README for documentation on using the plugin.
</a>
</p>
</div>
</div>
)
}
}
export default IndexComponent
export const query = graphql`
query FrontPageQuery {
imageSharp(id: { regex: "/nasa/" }) {
responsiveSizes(maxWidth: 1500) {
base64
aspectRatio
src
srcSet
sizes
originalImg
originalName
}
}
}
`