Skip to content

Instantly share code, notes, and snippets.

@prisme
Forked from Duaner/new-slice.md
Created April 18, 2017 14:52
Show Gist options
  • Save prisme/01a7a0046279106cf86b94f65c34c366 to your computer and use it in GitHub Desktop.
Save prisme/01a7a0046279106cf86b94f65c34c366 to your computer and use it in GitHub Desktop.
Include New slices in your nodejs project

#Define


"new-slice" : {
    "type" : "Slice",
    //No repeatable zone
    "non-repeat" : {
      "titre" : {
        "type" : "StructuredText"
      }
    },
    //Repeatable zone
    "repeat" : {
      "toto" : {
        "type" : "StructuredText"
      },
      "icon" : {
        "type" : "Image"
      }
    }
  }
  

#INTEGRATE


for slice in pageContent.getSliceZone('page.slice').slices
        //- Render the right markup for a given slice type.
        case slice.sliceType
            when 'new-slice'
                != slice.nonRepeat.titre.asHtml()
                // the repeat part of the slices is treated as Group - see the docs https://prismic.io/docs/fields/group#integrate?lang=javascript
                each item in slice.repeat.toArray() 
                    != item.getStructuredText('toto').asHtml()
                    

the repeat part of the slices is treated as Group - see the docs https://prismic.io/docs/fields/group#integrate?lang=javascript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment