Unlock seamless workflows and faster delivery with our latest releases – get the details

Build issues with Gatsby on Sanity blog starter project

12 replies
Last updated: Apr 28, 2020
Hey all! Has anyone had any build issues when trying to run a gatsby build on the Sanity blog starter project? I am getting this…
Apr 27, 2020, 2:38 PM
Thanks for the heads up, User! There should be a line at the top of that file:
const {format} = require('date-fns')
It should also check for empty
publishedAt
fields in the GraphQL query. I’ll check if I can reproduce the issue 👍
Apr 27, 2020, 2:51 PM
Thanks User. Yes I see it. I do have a draft that’s not been published and without a date. That’s been the only change on the project so far..
Apr 27, 2020, 2:57 PM
The graphql does filter them…

filter: { slug: { current: { ne: null } }, publishedAt: { ne: null } }
Apr 27, 2020, 2:58 PM
I had the same kind of problem with date in Gatsby before: that was a matter of date format. Here I see
YYYY/MM
and Gatsby only accept
YYYY-MM
or may be complete
YYYY-MM-DD
. I am not sure though.
Apr 27, 2020, 3:45 PM
Here is a data dump of the data it’s looping through.
Apr 27, 2020, 4:02 PM
Hi again User, I just tried to replicate the issue by starting from scratch at https://www.sanity.io/create with the Gatsby blog template. However, it successfully runs
gatsby develop
and
gatsby build && gatsby serve
in /web, as well as
npm run build
in root. So it looks like we need to dive in deeper to figure out what the issue is.
You created your project via
sanity.io/create , correct? And you get the error when running your build locally? Have you tried re-creating the blog from scratch?
Apr 27, 2020, 6:32 PM
That’s correct yeah. Haven’t tried re-creating it from scratch… i’ll give it a try tomorrow and see how I get on and let you know. Thanks for looking into it User 👍
Apr 27, 2020, 7:57 PM
Ok, so I can confirm that the problem was upgrading the projects dependencies. (forgot that I did that, sorry). So it appears to be a problem with 1 or more of the following deps. (Not including latest gatsby as it still builds on the below version)
Apr 28, 2020, 11:36 AM
Might be worth trying to replicate with that and see if you have the same build problem. I’m unable to go through each dependancie at the moment to see which ones are causing the problems, but if you’d like me to when i’m able, please let me know 🙂
Apr 28, 2020, 11:37 AM
There does seem to be a particular issue around using the latest date-fns, for which
user S
gave a possible work around. with the below

import { format, parseISO } from 'date-fns'
...
const dateSegment = format(parseISO(publishedAt), 'yyyy/MM')
Apr 28, 2020, 11:39 AM
Hi again User, thanks for confirming and for sharing all these extra details 👍 Looks like we have to do some maintenance to bring the template up to the latest version of
date-fns
without breaking it 🙂 Hope you can move forward for now, but I’ll ping you when we release an update.
Apr 28, 2020, 11:55 AM
Thanks User, that would be great. Thanks for your help on this 👍
Apr 28, 2020, 2:40 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?