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

Allow us to generate Contentful image fluid and fixed props outside of Graphql #24633

Closed
daydream05 opened this issue May 30, 2020 · 2 comments
Closed
Labels
stale? Issue that may be closed soon due to the original author not responding any more. topic: source-contentful Related to Gatsby's integration with Contentful type: feature or enhancement Issue that is not a bug and requests the addition of a new feature or enhancement.

Comments

@daydream05
Copy link
Contributor

daydream05 commented May 30, 2020

Summary

Generate fluid props without using graphql so we can use gatby-image in Contentful Rich Text

Basic example

import {  resolveFluid } from 'gatsby-source-contentful'

const fluidProps = resolveFluid(assetFromContentful, { maxWidth: 300, maxHeight: 400 })

<Img  fluidProps={assetFromContentful} />

The code is written already inside gatsby-source-contentful under extend-node-type.js we just need a way to access it!

Motivation

Folks that are using Contentful's Rich Text are having a hard time implementing gatsby-image when they render the node coming from the rich text data. Since all it's returning is the asset data. With no access to GatsbyContentfulFluid or GatsbyContentfulFluid fragments.

The current solutions are very hacky or could slow down whole gatsby sites.

I was inspired by how Sanity's gatsby source allows users to access gatsby-image outside of gatsby with a simple api.

Proof of concept

Here's a gist. All copy pasted from extend-node-type with just a slight rename of the api

@daydream05 daydream05 added the type: feature or enhancement Issue that is not a bug and requests the addition of a new feature or enhancement. label May 30, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 30, 2020
@LekoArts LekoArts added topic: source-contentful Related to Gatsby's integration with Contentful and removed effort: low status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jun 2, 2020
@github-actions
Copy link

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jun 22, 2020
@github-actions
Copy link

github-actions bot commented Jul 2, 2020

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.
Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 💪💜

@github-actions github-actions bot closed this as completed Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more. topic: source-contentful Related to Gatsby's integration with Contentful type: feature or enhancement Issue that is not a bug and requests the addition of a new feature or enhancement.
Projects
None yet
Development

No branches or pull requests

2 participants