Skip to content

Instantly share code, notes, and snippets.

@prisme
Created April 18, 2017 08:38
Show Gist options
  • Save prisme/358f1c78e908f0dabd700a5f2803693a to your computer and use it in GitHub Desktop.
Save prisme/358f1c78e908f0dabd700a5f2803693a to your computer and use it in GitHub Desktop.
hybrid slices
app.route('/').get(function(req, res){
api(req, res)
.then(function(api) {
api.query( prismic.Predicates.at('document.type', 'home-page') )
.then((pageContent) => {
if (pageContent) {
res.render('index', {
pageContent : pageContent.results[0],
});
} else {
res.status(404).send('404 not found');
}
})
})
})
{
"Home Page" : {
"body" : {
"fieldset" : "page content",
"type" : "Slices",
"config" : {
"choices" : {
"intro" : {
"type" : "Slice",
"fieldset" : "Intro",
"non-repeat" : {
"logo" : {
"type" : "Image"
},
"text" : {
"type" : "StructuredText",
"fieldset" : "Text",
"config" : {
"multi" : "paragraph",
"label" : "text",
"placeholder" : "intro text"
}
}
},
"repeat" : {
"image" : {
"type" : "Image",
"config" : {
"label" : "gallery image"
}
}
}
}
}
}
}
}
}
div
- var sliceZone = pageContent.getSliceZone('home-page.body') || {}
for slice in sliceZone.slices
case slice.sliceType
when 'intro'
// - var images = ??
// - var text = ??
// - var text = slice.nonRepeat.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment