Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from gatsbyjs:master #458

Merged
merged 3 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/create-gatsby/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.2.0-next.1](https://github.com/gatsbyjs/gatsby/compare/[email protected]@1.2.0-next.1) (2021-03-19)

### Bug Fixes

- **gatsby-plugin-netlify:** upgrade webpack-assets-manifest for compatibility with webpack@5 ([#30217](https://github.com/gatsbyjs/gatsby/issues/30217)) ([ca44a9e](https://github.com/gatsbyjs/gatsby/commit/ca44a9eb04878919ee52874a5e879a1a29ee0463))

# [1.2.0-next.0](https://github.com/gatsbyjs/gatsby/compare/[email protected]@1.2.0-next.0) (2021-03-11)

**Note:** Version bump only for package create-gatsby
Expand Down
2 changes: 1 addition & 1 deletion packages/create-gatsby/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-gatsby",
"version": "1.2.0-next.0",
"version": "1.2.0-next.1",
"main": "lib/index.js",
"bin": "cli.js",
"license": "MIT",
Expand Down
4 changes: 4 additions & 0 deletions packages/gatsby-admin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.12.0-next.1](https://github.com/gatsbyjs/gatsby/compare/[email protected]@0.12.0-next.1) (2021-03-19)

**Note:** Version bump only for package gatsby-admin

# [0.12.0-next.0](https://github.com/gatsbyjs/gatsby/compare/[email protected]@0.12.0-next.0) (2021-03-11)

**Note:** Version bump only for package gatsby-admin
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-admin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-admin",
"version": "0.12.0-next.0",
"version": "0.12.0-next.1",
"main": "index.js",
"author": "Max Stoiber",
"license": "MIT",
Expand All @@ -20,7 +20,7 @@
"@typescript-eslint/parser": "^4.14.2",
"csstype": "^2.6.14",
"formik": "^2.2.6",
"gatsby": "^3.2.0-next.0",
"gatsby": "^3.2.0-next.1",
"gatsby-interface": "^0.0.244",
"gatsby-plugin-typescript": "^3.2.0-next.0",
"gatsby-plugin-webfonts": "^1.1.4",
Expand Down
4 changes: 4 additions & 0 deletions packages/gatsby-cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [3.2.0-next.1](https://github.com/gatsbyjs/gatsby/compare/[email protected]@3.2.0-next.1) (2021-03-19)

**Note:** Version bump only for package gatsby-cli

# [3.2.0-next.0](https://github.com/gatsbyjs/gatsby/compare/[email protected]@3.2.0-next.0) (2021-03-11)

**Note:** Version bump only for package gatsby-cli
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby-cli",
"description": "Gatsby command-line interface for creating new sites and running Gatsby commands",
"version": "3.2.0-next.0",
"version": "3.2.0-next.1",
"author": "Kyle Mathews <[email protected]>",
"bin": {
"gatsby": "cli.js"
Expand All @@ -18,7 +18,7 @@
"common-tags": "^1.8.0",
"configstore": "^5.0.1",
"convert-hrtime": "^3.0.0",
"create-gatsby": "^1.2.0-next.0",
"create-gatsby": "^1.2.0-next.1",
"envinfo": "^7.7.3",
"execa": "^3.4.0",
"fs-exists-cached": "^1.0.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/gatsby-plugin-image/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.2.0-next.1](https://github.com/gatsbyjs/gatsby/compare/[email protected]@1.2.0-next.1) (2021-03-19)

### Bug Fixes

- **gatsby-plugin-image:** Better StaticImage errors ([#30271](https://github.com/gatsbyjs/gatsby/issues/30271)) ([8a0a4e8](https://github.com/gatsbyjs/gatsby/commit/8a0a4e82e3c782393621608a294b4b23b1e6753d))
- **gatsby-plugin-image:** image partial rendering ([#30221](https://github.com/gatsbyjs/gatsby/issues/30221)) ([d97a086](https://github.com/gatsbyjs/gatsby/commit/d97a0868acdbde2361175b4b1491d3adb6ac68bc))

# [1.2.0-next.0](https://github.com/gatsbyjs/gatsby/compare/[email protected]@1.2.0-next.0) (2021-03-11)

**Note:** Version bump only for package gatsby-plugin-image
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-image/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gatsby-plugin-image",
"version": "1.2.0-next.0",
"version": "1.2.0-next.1",
"scripts": {
"build": "npm-run-all -s clean -p build:*",
"build:gatsby-node": "tsc --jsx react --downlevelIteration true --skipLibCheck true --esModuleInterop true --outDir dist/ src/gatsby-node.ts src/babel-plugin-parse-static-images.ts src/resolver-utils.ts src/types.d.ts -d --declarationDir dist/src",
Expand Down
116 changes: 115 additions & 1 deletion packages/gatsby-plugin-image/src/components/__tests__/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { Node } from "gatsby"
import { getSrc, getSrcSet, getImage, IGatsbyImageData } from "../../"
import {
getSrc,
getSrcSet,
getImage,
IGatsbyImageData,
IGetImageDataArgs,
} from "../../"
import { getImageData } from "../hooks"

const imageData: IGatsbyImageData = {
images: {
Expand Down Expand Up @@ -34,7 +41,114 @@ const fileNode = {
childImageSharp: dataParent,
}

const getImageDataArgs: IGetImageDataArgs = {
baseUrl: `https://example.com/img/1234.jpg`,
urlBuilder: ({ baseUrl, width, height, format }): string =>
`${baseUrl}/${width}x${height}.${format}`,
sourceWidth: 1600,
sourceHeight: 1200,
}

describe(`The image helper functions`, () => {
describe(`getImageData`, () => {
it(`generates default data`, () => {
const data = getImageData(getImageDataArgs)
expect(data).toMatchInlineSnapshot(`
Object {
"backgroundColor": undefined,
"height": 1200,
"images": Object {
"fallback": Object {
"sizes": "(min-width: 1600px) 1600px, 100vw",
"src": "https://example.com/img/1234.jpg/1600x1200.auto",
"srcSet": "https://example.com/img/1234.jpg/400x300.auto 400w,
https://example.com/img/1234.jpg/800x600.auto 800w,
https://example.com/img/1234.jpg/1600x1200.auto 1600w",
},
"sources": Array [],
},
"layout": "constrained",
"width": 1600,
}
`)
})
it(`generates data with explicit dimensions`, () => {
const data = getImageData({ ...getImageDataArgs, width: 600 })
expect(data.images.fallback.srcSet).toMatchInlineSnapshot(`
"https://example.com/img/1234.jpg/150x113.auto 150w,
https://example.com/img/1234.jpg/300x225.auto 300w,
https://example.com/img/1234.jpg/600x450.auto 600w,
https://example.com/img/1234.jpg/1200x900.auto 1200w"
`)
expect(data.images.fallback.sizes).toEqual(
`(min-width: 600px) 600px, 100vw`
)
})

it(`generates full width data with all breakpoints`, () => {
const data = getImageData({
...getImageDataArgs,
layout: `fullWidth`,
})
expect(data.images.fallback.srcSet).toMatchInlineSnapshot(`
"https://example.com/img/1234.jpg/320x240.auto 320w,
https://example.com/img/1234.jpg/654x491.auto 654w,
https://example.com/img/1234.jpg/768x576.auto 768w,
https://example.com/img/1234.jpg/1024x768.auto 1024w,
https://example.com/img/1234.jpg/1366x1025.auto 1366w,
https://example.com/img/1234.jpg/1600x1200.auto 1600w"
`)
})

it(`generates full width data with explicit breakpoints`, () => {
const data = getImageData({
...getImageDataArgs,
layout: `fullWidth`,
breakpoints: [100, 200, 300, 1024, 2048],
})
expect(data.images.fallback.srcSet).toMatchInlineSnapshot(`
"https://example.com/img/1234.jpg/100x75.auto 100w,
https://example.com/img/1234.jpg/200x150.auto 200w,
https://example.com/img/1234.jpg/300x225.auto 300w,
https://example.com/img/1234.jpg/1024x768.auto 1024w,
https://example.com/img/1234.jpg/1600x1200.auto 1600w"
`)
})

it(`generates data with explicit formats`, () => {
const data = getImageData({
...getImageDataArgs,
formats: [`jpg`, `webp`, `avif`],
})
expect(data.images).toMatchInlineSnapshot(`
Object {
"fallback": Object {
"sizes": "(min-width: 1600px) 1600px, 100vw",
"src": "https://example.com/img/1234.jpg/1600x1200.jpg",
"srcSet": "https://example.com/img/1234.jpg/400x300.jpg 400w,
https://example.com/img/1234.jpg/800x600.jpg 800w,
https://example.com/img/1234.jpg/1600x1200.jpg 1600w",
},
"sources": Array [
Object {
"sizes": "(min-width: 1600px) 1600px, 100vw",
"srcSet": "https://example.com/img/1234.jpg/400x300.webp 400w,
https://example.com/img/1234.jpg/800x600.webp 800w,
https://example.com/img/1234.jpg/1600x1200.webp 1600w",
"type": "image/webp",
},
Object {
"sizes": "(min-width: 1600px) 1600px, 100vw",
"srcSet": "https://example.com/img/1234.jpg/400x300.avif 400w,
https://example.com/img/1234.jpg/800x600.avif 800w,
https://example.com/img/1234.jpg/1600x1200.avif 1600w",
"type": "image/avif",
},
],
}
`)
})
})
describe(`getImage`, () => {
it(`returns the same data if passed gatsbyImageData`, () => {
expect(getImage(imageData)).toEqual(imageData)
Expand Down
Loading