Closed jpvalery closed 5 years ago
You'll need to built a content model in Contentful.
Here's the GraphQL query from the Index of this repo: https://github.com/iammatthias/net/blob/master/src/pages/index.js
export const query = graphql`
query Index {
allContentfulExtendedGallery(
limit: 1000
sort: { fields: [publishDate], order: DESC }
) {
edges {
node {
title
id
slug
publishDate(formatString: "DD MMM YYYY h:mm a")
heroImage {
title
fluid(maxWidth: 1000) {
...GatsbyContentfulFluid_withWebp
}
}
body {
childMarkdownRemark {
excerpt(pruneLength: 140)
}
}
}
}
}
contentfulHome {
title
id
heroImage {
title
fluid(maxWidth: 1000) {
...GatsbyContentfulFluid_withWebp
}
ogimg: resize(width: 900) {
src
width
height
}
}
body {
childMarkdownRemark {
html
}
}
}
}
`
You would need to create content types for ExtendedGallery
and Home
, with the respective fields. The Home type is probably the easiest to replicate.
Home
Best of luck, hope this helps!
Thanks for the fast reply Matthias.
Just to make sure I got that right, it should look like this?
Besides the ExtendedGallery and Home, are there any other content models I should create? If you'd rather not disclose this publicly, you could send me that privately
Thank you so much for your help
Hey @jpvalery, I don't mind disclosing it. It can all be pieced together from the public GraphQL snippets, after all.
Content models are as follows:
I think that's all that is explicitly needed to get the galleries working. There are other basic models for the blog and contact page, but they're lifted from GCN.
I have some extra fields in Contentful right now that are not being used in the production version of my site at the moment. Some of them, like Meta Description, can be ignored for the most part.
Hey @iammatthias ,
Thank you so much for this. I figured most of it but apparently, I overlooked some parts.
Will let you know once this goes live :) Thanks again!
Looking forward to it, @jpvalery! Looking forward to seeing what you build.
Hello guys, I really avoid to ask for help but I don't get this.. I installed gatsby @iammatthias lasted package, changed the contentful IDs, changed the contentful structure of content to fit what's specified in one of the upper comment.
But then when i run "Gastby develop/build" I get the following error : ... success building schema - 0.205 s ⠋ createPages error UNHANDLED REJECTION
TypeError: Cannot read property 'allContentfulPost' of undefined
I don't understand what to do.. I thought that maybe it's because there wasn't any data in contentful so I created some, but no changes. Did I forget something? What am I doing wrong ?
I would really apreciate some help.
This repo is not intended to be a starter—it is the codebase for my personal site. It is left public to serve as an educational resource. Feel free to take a look at how things work, so you can build your own, but support is no longer provided.
If you would like to quickly bootstrap a Gatsby + Contentful + Netlify project, I recommend the fantastic GCN starter. It has an MIT license, unlike this project.
Hi Matthias,
Really digging this. I'd love to use it as a basis to redo my portfolio and learn some new skills with Gatsby/Contentful/Netlify.
Would you be open to share/extrapolate on the Contentful structure you're referring to?
Thanks in advance for your help!