gatsby

Gatsby Pagination for multiple pages [closed]

落花浮王杯 提交于 2020-04-17 14:19:56
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 days ago . Most of the Gatsby tutorials I've seen deal with one single source of pagination. For my site, I have multiple pages that use GraphQL to filter different categories of 160+ of blog posts. I need some way to paginate each category page, so users don't have to scroll down dozens of

Gatsby initial rerender on client side bug

≡放荡痞女 提交于 2020-03-25 18:48:47
问题 So, I have been investigating this bug for a while now and I think I got to the root cause of it. I have a navbar that changes if the user is logged in or not. On server render (I am using gatsby), this property is obviously always false meaning that I will get the guest navbar from the server on initial render. I have the following hook for checking isLoggedIn: import { useContext, useState, useEffect } from 'react'; import { UserContext } from '../contexts/UserContext'; import {

React Component not rendering source content when is part of another component and warning

谁说胖子不能爱 提交于 2020-03-25 13:52:13
问题 I am using MDX to display a component and its contents. I was able to get help from a SO member to get things moving along, however when using MDX + Gatsby components are not rendering as expected. Here you can see a minimal project working: https://codesandbox.io/s/gatsby-starter-mdx-basic-21mif <ShowHtml> <Test /> </ShowHtml> using gatsby-browser.js we are able to provide the components through MDXProvider import React from "react"; import { MDXProvider } from "@mdx-js/react"; import

React Component not rendering source content when is part of another component and warning

丶灬走出姿态 提交于 2020-03-25 13:48:57
问题 I am using MDX to display a component and its contents. I was able to get help from a SO member to get things moving along, however when using MDX + Gatsby components are not rendering as expected. Here you can see a minimal project working: https://codesandbox.io/s/gatsby-starter-mdx-basic-21mif <ShowHtml> <Test /> </ShowHtml> using gatsby-browser.js we are able to provide the components through MDXProvider import React from "react"; import { MDXProvider } from "@mdx-js/react"; import

Deploy gatsby site to netlify with --prefix-paths

删除回忆录丶 提交于 2020-03-23 23:51:42
问题 I'm trying to deploy a blog site built with Gatsby to Netlify. The thing is, I want to serve the site from /blog. Following the docs, I changed the gatsby-config.js to include pathPrefix like so: module.exports = { pathPrefix: `/blog`, siteMetadata: {...}, plugins: [...] } Next, I changed my build command to include --prefix-paths: gatsby build --prefix-paths When I run the site locally using gatsby serve --prefix-paths everything works fine. However, after I deployed to netlify the site is

Fastest way to add pre-existing static HTML page to a React/Gatsby site

拈花ヽ惹草 提交于 2020-03-18 05:14:08
问题 I have a simple project working nicely using JSX / React / Gatsby. I have a pre-existing page (think landing page) in HTML in another project, quite complex, nicely styled using Bootstrap 4, let's call it LandingPage.html and an associated LandingPage.css. I would like to add the landing page to my Gatsby site. So that for example when navigating to localhost:3000/LandingPage.html the landing page gets shown, properly styled etc. I am not clear whether I have to fully convert my pre-existing

GatsbyJs client only paths goes to 404 page when the url is directly accessed in browser in “production”

自作多情 提交于 2020-03-13 07:19:52
问题 I have created a Gatsby app and configured gatsby-node.js to a create client only paths, which are all working fine in development while directly accessing the url of the path but not in production. example : if(page.path.match(/^\/sample/)){ page.matchPath = "/sample/:value1/:value2/:value3"; createPage(page) } I am using heroku to deploy the app 回答1: The Why While the client-side router knows about this path, there is no corresponding HTML file. When the browser looks at the site it first

Redirect HTTP traffic to HTTPS in Gatsby

笑着哭i 提交于 2020-03-05 04:22:50
问题 I would like to redirect HTTP traffic to HTTPS as this is a Lighthouse requirement for PWAs. My site is built with Gatsby. I found various plugins like the ones below which seem to imply that the answer comes from modifying the .htaccess file. https://www.gatsbyjs.org/packages/gatsby-plugin-htaccess/ For the plugin above, I tried the following configuration, which didn't pass the PWA audit: { resolve: 'gatsby-plugin-htaccess', options: { RewriteBase: '/custom/', https: true, www: true,

Gatsby build error on Netlify: error Multiple “root” queries found in file

时光总嘲笑我的痴心妄想 提交于 2020-03-03 14:02:00
问题 I cannot make a build on Netlify but I did it successfully in my terminal on macOS. What does "root queries" mean?, does anyone got same issue ? Here's the log from netlify: 11:10:25 AM: success createPagesStatefully - 0.217s 11:10:25 AM: success onPreExtractQueries - 0.000s 11:10:25 AM: success update schema - 0.065s 11:10:25 AM: error Multiple "root" queries found in file: "headerTitleQuery" and "headerTitleQuery". 11:10:25 AM: Only the first ("headerTitleQuery") will be registered. 11:10

How to unpublish a gatsby page without deleting it?

牧云@^-^@ 提交于 2020-03-03 06:04:31
问题 I used a Gatsby starter for my static site, and one of the pages included in that starter is a demo page with all of the UI elements. I want to keep the page (so I can copy and paste from the demo) but don't want to be publicly available. How do I "unpublish" without deleting the file? Is there a way to tell gatsby-node.js to skip that page when generating the public facing site? 回答1: There are a bunch of Gatsby Node API helpers that you can use, one being deletePage. If you have a page src