【问题标题】:Gatsby config file for each page每个页面的 Gatsby 配置文件
【发布时间】:2018-08-27 20:54:47
【问题描述】:

我想使用 Gatsby 创建静态网站。我的问题是,我可以为gatsby-config.json 中的所有页面(路由)添加所有元数据吗?

这是 Gatsby 配置的示例:

module.exports = {
  siteMetadata: {
    title: 'Gatsby Default Starter',
  },
  plugins: ['gatsby-plugin-react-helmet'],
};

【问题讨论】:

    标签: javascript reactjs gatsby


    【解决方案1】:

    您可以将任何数据添加到您想要的siteMetadata。然后,您可以通过 GraphQL(在您的页面/模板/布局中)或通过 StaticQuery(仅在 Gatsby v2 中可用)查询它。

    看看官方教程: https://www.gatsbyjs.org/tutorial/part-four/#querying-for-the-site-title

    它向您展示了如何查询和使用gatsby-config.js 中的数据。

    【讨论】:

      猜你喜欢
      • 2021-10-12
      • 2019-10-01
      • 2018-09-03
      • 1970-01-01
      • 1970-01-01
      • 2016-08-09
      • 2023-03-30
      • 1970-01-01
      • 2021-04-13
      相关资源
      最近更新 更多