Skip to content

Commit

Permalink
fix(gatsby-source-contentful): De-dupe type names (#30834)
Browse files Browse the repository at this point in the history
* fix(gatsby-source-contentful): De-dupe layout type name

* Add placeholder type too

(cherry picked from commit 71ec0cd)
  • Loading branch information
ascorbic authored and vladar committed Apr 13, 2021
1 parent e40c83d commit 1f4dc0d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/gatsby-source-contentful/src/extend-node-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const {
ImageFormatType,
ImageResizingBehavior,
ImageCropFocusType,
ImageLayoutType,
ImagePlaceholderType,
} = require(`./schemes`)

// By default store the images in `.cache` but allow the user to override
Expand Down Expand Up @@ -790,6 +792,25 @@ exports.extendNodeType = ({ type, store }) => {
type: GraphQLInt,
defaultValue: 50,
},
layout: {
type: ImageLayoutType,
description: stripIndent`
The layout for the image.
CONSTRAINED: Resizes to fit its container, up to a maximum width, at which point it will remain fixed in size.
FIXED: A static image size, that does not resize according to the screen width
FULL_WIDTH: The image resizes to fit its container, even if that is larger than the source image.
Pass a value to "sizes" if the container is not the full width of the screen.
`,
},
placeholder: {
type: ImagePlaceholderType,
description: stripIndent`
Format of generated placeholder image, displayed while the main image loads.
BLURRED: a blurred, low resolution image, encoded as a base64 data URI (default)
DOMINANT_COLOR: a solid color, calculated from the dominant color of the image.
TRACED_SVG: a low-resolution traced SVG of the image.
NONE: no placeholder. Set the argument "backgroundColor" to use a fixed background color.`,
},
formats: {
type: GraphQLList(ImageFormatType),
description: stripIndent`
Expand Down
21 changes: 21 additions & 0 deletions packages/gatsby-source-contentful/src/schemes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@ const ImageFormatType = new GraphQLEnumType({
},
})

const ImageLayoutType = new GraphQLEnumType({
name: `ContentfulImageLayout`,
values: {
FIXED: { value: `fixed` },
FULL_WIDTH: { value: `fullWidth` },
CONSTRAINED: { value: `constrained` },
},
})

const ImagePlaceholderType = new GraphQLEnumType({
name: `ContentfulImagePlaceholder`,
values: {
DOMINANT_COLOR: { value: `dominantColor` },
TRACED_SVG: { value: `tracedSVG` },
BLURRED: { value: `blurred` },
NONE: { value: `none` },
},
})

const ImageResizingBehavior = new GraphQLEnumType({
name: `ImageResizingBehavior`,
values: {
Expand Down Expand Up @@ -59,6 +78,8 @@ const ImageCropFocusType = new GraphQLEnumType({
})

module.exports = {
ImageLayoutType,
ImagePlaceholderType,
ImageFormatType,
ImageResizingBehavior,
ImageCropFocusType,
Expand Down

0 comments on commit 1f4dc0d

Please sign in to comment.