gatsby

How do you publish a gatsby project with gatsby-image on Netlify?

瘦欲@ 提交于 2021-01-02 03:47:24
问题 So I can locally build my gatsby project no problem, but when Netlify tries to build, I get the error Field "featuredImage" must not have a selection since type "String" has no subfields. 5:34:38 PM: This can happen if you e.g. accidentally added { } to the field "featuredImage". If you didn't expect "featuredImage" to be of type "String" make sure that your input source and/or plugin is correct. 5:34:38 PM: error There was an error in your GraphQL query: 5:34:38 PM: Field "featuredImage"

How set up a Gatsby Cookie consent banner with gatsby-plugin-gdpr-cookies

≡放荡痞女 提交于 2020-12-25 01:04:45
问题 My website gathers information for Google Analytics, so I need to include a Cookie consent banner for the users to opt in/out of. I saw the plugin gatsby-plugin-gdpr-cookies and thought it looked perfect. I've followed the startup and have it inside my config file. However I'm not sure what to do next. Do I need to create a banner component and link it all up somehow? I've tried to look around for other examples but can't see any. Any help appreciated, thanks. 回答1: You have to combine a

How set up a Gatsby Cookie consent banner with gatsby-plugin-gdpr-cookies

强颜欢笑 提交于 2020-12-25 01:00:00
问题 My website gathers information for Google Analytics, so I need to include a Cookie consent banner for the users to opt in/out of. I saw the plugin gatsby-plugin-gdpr-cookies and thought it looked perfect. I've followed the startup and have it inside my config file. However I'm not sure what to do next. Do I need to create a banner component and link it all up somehow? I've tried to look around for other examples but can't see any. Any help appreciated, thanks. 回答1: You have to combine a

How set up a Gatsby Cookie consent banner with gatsby-plugin-gdpr-cookies

倾然丶 夕夏残阳落幕 提交于 2020-12-25 00:56:10
问题 My website gathers information for Google Analytics, so I need to include a Cookie consent banner for the users to opt in/out of. I saw the plugin gatsby-plugin-gdpr-cookies and thought it looked perfect. I've followed the startup and have it inside my config file. However I'm not sure what to do next. Do I need to create a banner component and link it all up somehow? I've tried to look around for other examples but can't see any. Any help appreciated, thanks. 回答1: You have to combine a

How set up a Gatsby Cookie consent banner with gatsby-plugin-gdpr-cookies

落爺英雄遲暮 提交于 2020-12-25 00:52:14
问题 My website gathers information for Google Analytics, so I need to include a Cookie consent banner for the users to opt in/out of. I saw the plugin gatsby-plugin-gdpr-cookies and thought it looked perfect. I've followed the startup and have it inside my config file. However I'm not sure what to do next. Do I need to create a banner component and link it all up somehow? I've tried to look around for other examples but can't see any. Any help appreciated, thanks. 回答1: You have to combine a

Gatsby MDX showing title and slug but doesn't find page

早过忘川 提交于 2020-12-15 06:39:47
问题 I'm learning Gatsby and I wanted to use MDX for blog pages. I followed the tutorial here to programmatically create pages. I can see them in my GraphQL, and displaying the list of all the articles is working with their title and slug, but when I click on the link to open them or type their address I have a 404 page. Do you have an idea from where it can come from? This is my code: gatsby-node.js: exports.onCreateNode = ({ node, actions, getNode }) => { const { createNodeField } = actions if

个人博客搭建

烈酒焚心 提交于 2020-12-13 12:48:55
个人博客搭建 经过 1 个月的咕咕咕,总算把博客初步搭建好了,按照惯例先丢个链接大家有兴趣可以来逛逛: blog.mytyiluo.cn 。 主要特点如下: Modernized - 基于 Gatsbyjs,React,Typescript 构建; Opinionated - 以约束优先,减少博客中的必需参数; Git-based - 基于 GitHub 以及 Netlify 的自动化构建/部署; 为什么不使用现有的博客框架? 之前其实一直用的是 GitBook,但说实话,GitBook 还是更加适合书籍/教程等的写作,对随笔来说还是感觉少了点功能。而且官方也表示之后不再维护命令行程序了,因此决定慢慢的从这平台迁移出来。 在这过程中,有考虑过使用 Hexo 作为博客引擎,想自己写一套主题,但无奈不习惯它的模板语法,最终还是选择了放弃。 然后,考虑到开发的难度和灵活性,决定使用基于 React 的静态网页引擎,也就是 GatsbyJS 。 其中,最吸引我的便是它对多数据源的内建支持,并以 GrapQL 的形式统一提供数据,非常符合我对后期拓展的预期。此外,丰富的社区插件倒算是额外的惊喜,特别是支持 TypeScript 和 Less 对开发带来了极大的方便,支持响应式图片和 PWA 也省去了我大量的精力。 我希望的博客体验 在本地用 VS Code 来编写 Markdown

Cache-busting page-data.json files in Gatsby

烈酒焚心 提交于 2020-12-12 07:37:32
问题 I have a gatsby generated website on which I have replaced the contents of the homepage. Unfortunately the previous version was serving up /page-data/index/page-data.json with the incorrect cache-control headers, resulting in /page-data/index/page-data.json being cached on client browsers (and stale data being shown unless force-refreshed). I have also discovered that page-data.json files are not hashed (see https://github.com/gatsbyjs/gatsby/issues/15080). I've updated the cache-control

React 组件化开发(二):最新组件api

生来就可爱ヽ(ⅴ<●) 提交于 2020-12-06 03:12:33
学习的过程,就是把已经实现的功能反复地,变着花样地 重构 ,直到找到最合适的点。 如果连这点觉悟都没有,那就不是一个合格的程序员。而雇主的本质是逐利,最忌讳的是重构,这个问题可以请高水平的工程师来得到 缓解 ,但不可能彻底解决。 本文知识要点 Hook 高阶组件 组件通信 上下文 React.cloneElement Hook 文档地址:https://zh-hans.reactjs.org/docs/hooks-intro.html#___gatsby hook是16.8版本新增的特性。它可以让你在不编写 class 的情况下使用 state 以及其他的 React 特性。 它具有如下特点: 在无需修改状态的情况下,复用状态逻辑。 将相关联的部分拆分为更小的函数,复杂组件将更容易理解。 更简洁,更易理解。 状态钩子 State Hook 函数型组件可以使用状态: function Example () { // 声明一个新的叫做 “count” 的 state 变量, // 数组第二个值是变更函数,参数接收的是新状态 // useState参数是初始值。 const [ count , setCount ] = useState ( 0 ); return ( <div> <p> You clicked { count } times </ p > < button