简体   繁体   中英

How to implement gatsby-remark-images-grid in markdown using Gatsby.js

I'm making a blog in Gatsby.js using markdown and I want to use css grid in my blogposts to display a nice grid of images.

So I know Gatsby has got fantastic plugins to solve almost every problem.

I found out about gatsby-remark-images-grid wich is suppos to solve my problem, but I can't seem to get it to work.

I did install it correctly (I think: npm install gatsby-remark-images-grid --save), put it in my gatsby-config.js, which looks like this:

module.exports = {
  siteMetadata: {
    title: 'Kids and Coconuts',
    siteUrl: 'https://kidsandcoconuts.com',
  },
  plugins: [
    'gatsby-plugin-react-helmet',
    `gatsby-plugin-sharp`,
    `gatsby-transformer-sharp`,
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: 'gatsby-starter-default',
        short_name: 'starter',
        start_url: '/',
        background_color: '#663399',
        theme_color: '#663399',
        display: 'minimal-ui',
        icon: 'src/images/gatsby-icon.png', // This path is relative to the root of the site.
      },
    },
    `gatsby-plugin-catch-links`,
    'gatsby-plugin-offline',
    {
      resolve: `gatsby-transformer-remark`,
      options: {
        plugins: [
          `gatsby-remark-prismjs`,

          {
            resolve: "gatsby-remark-images-grid",
            options: {

            },
        },

        ]
      }
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/content`,
        name: "pages",
      },
    },
  ],
}

and I tried to put a image grid in one of my blogpost:

```
![](../time.jpg)
![](../time.jpg)
```

Does somebody see what am I forgetting or doing wrong?

Tanks a million!

Define the path in the markdown file. If markdown files are in src/pages/index.md and in src/images/image.jpg you would put this in the MD file.

   images:
  - /images/image1.jpg
  - /images/image2.jpg
  - /images/image3.jpg

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM