-
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.
fix(gatsby-plugin-sharp): PathPrefix isn't being passed/set for Gatsb…
…yImage (#28845) (#28991) * fix for path-prefix in GatsbyImage * add e2e test for path prefix cases * update tests * forgot to save * refactor * add curlys (cherry picked from commit 5874414) Co-authored-by: LB <[email protected]>
- Loading branch information
GatsbyJS Bot
and
LB
authored
Jan 13, 2021
1 parent
1617c6c
commit c762050
Showing
7 changed files
with
92 additions
and
36 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,38 +1,57 @@ | ||
import * as React from "react" | ||
import { Link, navigate } from "gatsby" | ||
import { StaticImage } from "gatsby-plugin-image" | ||
import { Link, navigate, graphql } from "gatsby" | ||
import { StaticImage, GatsbyImage, getImage } from "gatsby-plugin-image" | ||
|
||
import Layout from "../components/layout" | ||
|
||
const IndexPage = () => ( | ||
<Layout> | ||
<h1>Hi people</h1> | ||
<StaticImage | ||
src="../images/gatsby-icon.png" | ||
alt="Gatsby icon" | ||
layout="fixed" | ||
/> | ||
<p>Welcome to your new Gatsby site.</p> | ||
<p>Now go build something great.</p> | ||
<Link data-testid="page-2-link" to="/page-2/"> | ||
Go to page 2 | ||
</Link> | ||
<Link data-testid="page-blogtest-link" to="/blogtest/"> | ||
Go to blogtest | ||
</Link> | ||
<button | ||
data-testid="page-2-button-link" | ||
onClick={() => navigate(`/page-2/`)} | ||
> | ||
Go to page 2 with navigate() | ||
</button> | ||
<Link data-testid="404-link" to="/not-existing-page"> | ||
Go to not existing page | ||
</Link> | ||
<Link data-testid="subdir-link" to="subdirectory/page-1"> | ||
Go to subdirectory | ||
</Link> | ||
</Layout> | ||
) | ||
const IndexPage = ({ data }) => { | ||
const image = getImage(data.file) | ||
return ( | ||
<Layout> | ||
<h1>Hi people</h1> | ||
<StaticImage | ||
src="../images/gatsby-icon.png" | ||
alt="Gatsby icon" | ||
layout="fixed" | ||
data-testid="static-image" | ||
/> | ||
<GatsbyImage | ||
image={image} | ||
alt="Citrus Fruits" | ||
data-testid="gatsby-image" | ||
/> | ||
<p>Welcome to your new Gatsby site.</p> | ||
<p>Now go build something great.</p> | ||
<Link data-testid="page-2-link" to="/page-2/"> | ||
Go to page 2 | ||
</Link> | ||
<Link data-testid="page-blogtest-link" to="/blogtest/"> | ||
Go to blogtest | ||
</Link> | ||
<button | ||
data-testid="page-2-button-link" | ||
onClick={() => navigate(`/page-2/`)} | ||
> | ||
Go to page 2 with navigate() | ||
</button> | ||
<Link data-testid="404-link" to="/not-existing-page"> | ||
Go to not existing page | ||
</Link> | ||
<Link data-testid="subdir-link" to="subdirectory/page-1"> | ||
Go to subdirectory | ||
</Link> | ||
</Layout> | ||
) | ||
} | ||
|
||
export const query = graphql` | ||
query { | ||
file(relativePath: { eq: "citrus-fruits.jpg" }) { | ||
childImageSharp { | ||
gatsbyImageData | ||
} | ||
} | ||
} | ||
` | ||
|
||
export default IndexPage |
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