简体   繁体   English

如何使用Gatsby.js在markdown中实现gatsby-remark-images-grid

[英]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. 我正在使用markdown在Gatsby.js中创建一个博客,我想在我的博客文章中使用CSS网格来显示漂亮的图像网格。

So I know Gatsby has got fantastic plugins to solve almost every problem. 因此,我知道Gatsby有出色的插件可以解决几乎所有问题。

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. 我发现关于gatsby-remark-images-grid的假设是可以解决我的问题的,但是我似乎无法使其正常工作。

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: 我确实正确安装了它(我认为:npm install gatsby-remark-images-grid --save),将其放入我的gatsby-config.js中,如下所示:

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. 如果markdown文件位于src/pages/index.mdsrc/images/image.jpg可以将其放入MD文件中。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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