Coder Social home page Coder Social logo

Comments (25)

matthewrobb avatar matthewrobb commented on June 29, 2024 1

What would be nice is if the validation didn't fail on an empty list or if you could do default: []

from gatsby-starter-bootstrap-netlify.

matthewrobb avatar matthewrobb commented on June 29, 2024 1

Yeah we're right on top of each other atm haha sorry.

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

Hmm, I get this if I don't have any markdown posts. Do you have some demo.posts? Can you link to a repo of your code? I can take a look.

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

@sw-yx did you get it working? again, if you link to your code, I can take a look.

from gatsby-starter-bootstrap-netlify.

matthewrobb avatar matthewrobb commented on June 29, 2024

I am still seeing this issue :/

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

I am not, so I'm happy to troubleshoot if you can provide a reproduction of the issue, and more information about your environment, but otherwise, I'm not sure what the issue might be.

Here is an asciinema of it working for me:

asciicast

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

Like the error above is literally saying "I found a post, but it's null, so I can't mess with it's frontmatter". This could be caused by a lot of things, but most likely cause, without anymore info, is there are missing post files (user-error.) I am happy to help if you can point me to a github of a project that fails.

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

A 2-second 1-line guard could probly fix it (the fact that there are no post files for it to index) but I'd rather see a "broken" example, before I write the code.

from gatsby-starter-bootstrap-netlify.

matthewrobb avatar matthewrobb commented on June 29, 2024

This is the error I am getting at build time in Netlify. The only CHANGE I made was to add required: false to attachments and to related posts.

https://github.com/matthewrobb/kj-home-on-the-mend/blob/master/static/admin/config.yml

5:50:18 PM: The GraphQL query from /opt/build/repo/src/templates/blog.js failed
5:50:18 PM:         Errors:
5:50:18 PM:           GraphQLError: Cannot read property 'id' of undefined
5:50:18 PM:         Query:
5:50:18 PM:           query BlogPostByPath(
5:50:18 PM:   $path: String!
5:50:18 PM: ) {
5:50:18 PM:   site {
5:50:18 PM:     siteMetadata {
5:50:18 PM:       disqus
5:50:18 PM:     }
5:50:18 PM:   }
5:50:18 PM:   markdownRemark(frontmatter: {path: {eq: $path}}) {
5:50:18 PM:     html
5:50:18 PM:     frontmatter {
5:50:18 PM:       path
5:50:18 PM:       date(formatString: "MMMM DD, YYYY")
5:50:18 PM:       title
5:50:18 PM:       attachments {
5:50:18 PM:         filename
5:50:18 PM:       }
5:50:18 PM:       related {
5:50:18 PM:         post
5:50:18 PM:       }
5:50:18 PM:     }
5:50:18 PM:   }
5:50:18 PM:   allMarkdownRemark {
5:50:19 PM:     edges {
5:50:19 PM:       node {
5:50:19 PM:         frontmatter {
5:50:19 PM:           title
5:50:19 PM:           path
5:50:19 PM:         }
5:50:19 PM:       }
5:50:19 PM:     }
5:50:19 PM:   }
5:50:19 PM: }

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

Thanks. I will take a look at your project. The main thing to keep in mind is it's not really netlify that does anything, other than triggering build (and providing auth & file-api to netlify-cms.) Changes to config.yml shouldn't affect how it builds, but the generated files might not be kosher with gatsby/this project, which will make the build fail. I am happy to make the templates & gatsby stuff ignore bad files, but "bad files" can mean a lot of different things.

Here is me installing & building yours:
asciicast

I get error:

error Unable to find plugin "gatsby-plugin-netlify-cms"

Since this isn't in my gatsby-config.js, I removed that line, and tried again, and got this error:

GraphQL Error Unknown field `attachments` on type `frontmatter`

  file: /Users/konsumer/Desktop/kj-home-on-the-mend/src/templates/blog.js

   5 |         disqus
   6 |       }
   7 |     }
   8 |
   9 |     markdownRemark(frontmatter: { path: { eq: $path } }) {
  10 |       html
  11 |       frontmatter {
  12 |         path
  13 |         date(formatString: "MMMM DD, YYYY")
  14 |         title
> 15 |         attachments {
     |         ^
  16 |           filename
  17 |         }
  18 |         related {
  19 |           post
  20 |         }
  21 |       }
  22 |     }
  23 |
  24 |     allMarkdownRemark{
  25 |       edges{

I looked through all the blog markdown files, and noticed none have attachments in frontmatter, so when gatsby tries to figure out what fields are in frontmatter, it has no way of guessing that you might eventually want attachments.

There are 2 quick fixes:

  • Remove the attachments part form the graphql query in src/templates/blog.js and remove any reference to attachments in component
  • add a blog post that has file attachments

from gatsby-starter-bootstrap-netlify.

matthewrobb avatar matthewrobb commented on June 29, 2024

I'm sorry that repo is stale from my local other than content files.... I am just jumping into this whole gatsby/netlify/static site gen world.

Looking at the md files you bundled vs the ones netlify cms is producing it looks as though the date: header field is quoted in the generated file but not in the ones in the starter repo. Not sure if this helps at all.

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

no prob. I hit "Comment" button too fast, updated my reply.

from gatsby-starter-bootstrap-netlify.

matthewrobb avatar matthewrobb commented on June 29, 2024

I almost feel as though it's an issue with the list widget in the schema. The files in this repo contain attachments: [] but if I make attachments required: false and then create a post it just omits the field

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

Agreed, and that's out of my control, really.

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

it's like a mix of 2 things:

  • gatsby dynamically adds fields to graphql-queryable object, based on what's there. This is super-handy (you can just add stuff to the frontmatter, and then query it) but if no content has the field, there isn't a simple way to make it available to a query
  • netlify-cms required leaves the field out if you don't set anything.

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

it might be silly, but like an "example" set of content-types, that are marked hidden might be the trick. like a dummy blog post, about-page, etc, that has all the fields. on list, leave it out, but when gatsby is trying to work out what fields to look at, it will take it into consideration.

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

Actually, just did that, and it worked. I should add that to the template-project. I kind of like that it also documents how to make a thing. I will re-open the issue until I get it in there, but in the meantime, here is your project, all fixed.

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

the main difference is that I added a file indexer for src/examples, ignored "hidden" files in index, and added some example-files.

from gatsby-starter-bootstrap-netlify.

matthewrobb avatar matthewrobb commented on June 29, 2024

You might want to go a step further as I am doing locally now and create essentially 2 stub files that reference each other where needed but also are marked hidden (I am trying to work this out now) and thus excluded from content lists and searches. The idea would be the stub posts should always flex the full capabilities of the content type.

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

That is what I did.

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

See here which fleshes out all the fields. You could basically do this with any content-type/fields, and then later check for hidden. A second-part fo this trick is that the examples are in another directory, so netlify-cms won't list them in "Blog", and they just act as a definition/docs for making new content. I think this will also make it so I can remove the dumb demo posts & images, and people can just explore the content-types by adding their own content.

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

Ok, changes are checked in, so new blogs made with this template will use the examples files. I also added greenkeeper & travis to keep the repo in good health.

from gatsby-starter-bootstrap-netlify.

konsumer avatar konsumer commented on June 29, 2024

closing for now, but feel free to make more comments if the issue pops up, again.

from gatsby-starter-bootstrap-netlify.

matthewrobb avatar matthewrobb commented on June 29, 2024

@konsumer Just wanted to let you know that I updated quite a few dependencies so I am not sure exactly what solved the initial problem but I am now able to keep those list widget fields as required but specifying default: [] and have it correctly output into the frontmatter.

from gatsby-starter-bootstrap-netlify.

swyxio avatar swyxio commented on June 29, 2024

eeps sorry for the driveby Issue report David Ive been slacking on my github notifications. I dont use this starter anymore so I cant really provide anymore input. sorry i didnt respond sooner!

from gatsby-starter-bootstrap-netlify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.