尝试在主要特色产品图片下方显示其他图片缩略图

Trying to Display Additional Image Thumbnails Below Main Featured Product Image

无法从 Moltin 获取文件 API 以显示在主要产品图片下

使用此存储库:https://github.com/moltin/gatsby-demo-store 并更新 @moltin/gatsby-source-moltin 到 1.3.1 我试过扩展产品 然后根据 Moltin API 文档包含关系的节点模式 在新组件中引用它但没有额外的图像渲染。

查看了其他实现,即使用的 Gatsby Store 示例 缩略图可以得到一个微小的可点击的紫色细条渲染但没有图像。该商店使用 Shopify 和 localFile 存储进行图像渲染,因此此用例不适用。

```
import React, { useContext, useEffect, useReducer, useState } from 'react'
import { graphql, withPrefix } from 'gatsby'

import SEO from '../components/SEO'
import Photo from '../components/Photo'
import Badge from '../components/Badge'
import AddToCart from '../components/AddToCart'
import { Shopkit } from '../shopkit'
import Img from 'gatsby-image'


  const {
    meta: { display_price }
  } = product

  return (
    <React.Fragment>
      <SEO
        type="product"
        title={product.meta_title || product.name}
        description={product.meta_description || product.description}
        image={withPrefix(product.mainImage.childImageSharp.fixed.src)}
      />

      <div className="flex flex-wrap md:bg-grey-light">
        <div className="py-2 md:py-5 md:px-5 w-full lg:w-1/2">
          <div className="sticky pin-t">
            <Photo
              src={product.mainImage}
              alt={product.main_image_alt_text || product.name}
            />
           <Img 
             src={product.relationships.files.data.id}
             alt=""
           />  
          </div>
        </div>
......
.....
....
    </React.Fragment>
  )
}

export const query = graphql`
  query($id: String!) {
    product: moltinProduct(id: { eq: $id }) {
      id
      slug
      name
      description
      sku
      mainImage {
        childImageSharp {
          fixed(width: 560) {
            ...GatsbyImageSharpFixed
          }
        }
        publicURL
      }
      meta {
        display_price {
          without_tax {
            formatted
          }
        }
      }
      manage_stock
      meta_title
      meta_description
      on_sale
      bulb
      bulb_qty
      material
      finish
      max_watt
      relationships {
             main_image {
              data {
                id
              }
            }
        files {
          data {
            type
            id
          }
    }
  }
`

export default ProductPage
```

想要在主产品图片下方显示小缩略图。安慰 使用 Img 组件时报错:Uncaught TypeError: Cannot read 属性 'src' 未定义。

gatsby-source-moltin 向产品模式添加一个 images 字段,您可以像这样查询:

images {
  childImageSharp {
    fluid(maxWidth: 300) {
      ...GatsbyImageSharpFluid
    }
  }
}

我在 CodeSandbox 上整理了一个示例。