Git Product home page Git Product logo

Comments (3)

iammatthias avatar iammatthias commented on July 1, 2024

https://github.com/iammatthias/Cali-Meets-Delhi/blob/master/src/pages/index.js

It’s all there in the GraphQL query! Tbh there are better ways of setting this up. I’d suggest checking out the Gatsby + Contentful rich text support: https://www.gatsbyjs.org/packages/gatsby-source-contentful/#contentful-rich-text

from cali-meets-delhi.

venelinn avatar venelinn commented on July 1, 2024

Hi again!
Thank for the references !
But I'm still new in GraphQL and It's hard to understand the structure.
So you have Model for each Section and then each section has own content model?? Am I right?

The only thing I'm not getting is the connection.

modules { __typename ... on ContentfulHero { title

Thank you !

from cali-meets-delhi.

iammatthias avatar iammatthias commented on July 1, 2024
query Index {
    allContentfulSection {
      edges {
        node {
          id
          title
          slug
          modules {
            __typename
            ... on ContentfulHero {
              title
              image {
                title
                fluid(maxWidth: 1200, quality: 80) {
                  ...GatsbyContentfulFluid_withWebp_noBase64
                }
              }
              logo {
                title
                description
                fluid(maxWidth: 800, quality: 80) {
                  ...GatsbyContentfulFluid_withWebp_noBase64
                }
              }
            }
         

So there is ContentfulSection, which is a content type with the following blocks: title, slug, and modules. Title is the page title/site title, slug isn’t really needed for this, and modules is a reference field.

Modules then references other content types. So modules { __typename ... on ContentfulHero { title is looking for the section title of the ContentfulHero content type. The rest of the GraphQL query pulls in other stuff from the Hero block - the hero image itself, and the “We’re Getting Married” image overlay. The rest of the query pulls in the other modules, like the Agenda section.

The problem with this module format is that it is ridged. If you want to change the order of the modules, you need to change the order in Contentful AND in your source code(in the modules component).

from cali-meets-delhi.

Related Issues (2)

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.