Coder Social home page Coder Social logo

Comments (4)

VdeVentura avatar VdeVentura commented on May 13, 2024

Is this related to the issue I was talking with you about using the plugin to display cover images (set in frontmatter, instead of referencing external images) in the post listing?

Something among the lines of this:

image

from gatsby-advanced-starter.

Vagr9K avatar Vagr9K commented on May 13, 2024

It is related but not limited to.
I want to add some general mechanisms to generate responsive images and embed them into HTML.

Unfortunately, no time to do that.

from gatsby-advanced-starter.

arcdev1 avatar arcdev1 commented on May 13, 2024

using the plugin to display cover images (set in frontmatter, instead of referencing external images) in the post listing?

This functionality is already available with gatsby-image.
https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-image

Steps to enable:

  1. Install dependencies
npm install gatsby-image --save
npm install gatsby-transformer-sharp --save
  1. Add plugin to gatsby-config.js
plugins: ['gatsby-transformer-sharp']
  1. Create an images folder under sample-posts
sample-posts
 /images
  1. Add some images to the new images folder

  2. Modify the cover property in the frontmatter of all blog posts to point to a local image

cover: "../images/some-image.jpg"
  1. Modify the queries in pages/index.jsx and templates/post.jsx to include the childImageSgarp node
cover
  {
    childImageSharp{
     sizes(maxWidth: 720, maxHeight: 400) {
        ...GatsbyImageSharpSizes
      }
    }
  }
  1. Import gatsby-image in templates/post.jsx
import Img from 'gatsby-image'
  1. Add an Img element to templates/post.jsx
<Img sizes={post.cover.childImageSharp.sizes} />

You can found out more about the options for childImageSharp at:
https://image-processing.gatsbyjs.org

Hope that helps!

from gatsby-advanced-starter.

Vagr9K avatar Vagr9K commented on May 13, 2024

Fixed in #33.

from gatsby-advanced-starter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.