Created
April 17, 2020 13:06
-
-
Save bytrangle/09892ae7e96dcee49d6fa818c2c29f51 to your computer and use it in GitHub Desktop.
Query images from Markdown files, then render them
This file contains hidden or 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
import React from "react" | |
import { Link, graphql } from "gatsby" | |
import Img from "gatsby-image" | |
import Layout from "../components/layout" | |
import Image from "../components/image" | |
import SEO from "../components/seo" | |
export default props => { | |
const { fixed } = props.data.fixedImage.childImageSharp | |
const { fluid } = props.data.fluidImage.childImageSharp | |
return ( | |
<Layout> | |
<SEO title="Home" /> | |
<h1>Hi people</h1> | |
<p>Welcome to your new Gatsby site.</p> | |
<p>Now go build something great.</p> | |
<div style={{ maxWidth: `300px`, marginBottom: `1.45rem` }}> | |
<Image /> | |
</div> | |
<Img fixed={fixed} /> | |
<Img fluid={fluid} /> | |
<Link to="/page-2/">Go to page 2</Link> | |
</Layout> | |
) | |
} | |
export const pageQuery = graphql` | |
query { | |
fixedImage: file( | |
relativePath: { eq: "james-mccullough-Znxkw16UKG0-unsplash.jpg" } | |
) { | |
childImageSharp { | |
fixed(height: 460) { | |
...GatsbyImageSharpFixed | |
} | |
} | |
} | |
fluidImage: file( | |
relativePath: { eq: "james-mccullough-Znxkw16UKG0-unsplash.jpg" } | |
) { | |
childImageSharp { | |
fluid(maxWidth: 700) { | |
...GatsbyImageSharpFluid | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment