This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prismic.Api('https://lesbonneschoses.prismic.io/api', function (err, Api) { | |
// You can use the Api object inside this block | |
console.log("References: ", Api.data.refs); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prismic.Api('https://lesbonneschoses.prismic.io/api', function (err, Api) { | |
// This will fail because the token is invalid, but this is how to access a private API | |
}, "MC5-XXXXXXX-vRfvv70"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// todo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// todo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var previewToken = 'MC5VbDdXQmtuTTB6Z0hNWHF3.c--_vVbvv73vv73vv73vv71EA--_vS_vv73vv70T77-9Ke-_ve-_vWfvv70ebO-_ve-_ve-_vQN377-9ce-_vRfvv70'; | |
Prismic.Api('https://lesbonneschoses.prismic.io/api', function (err, Api) { | |
var stPatrickRef = Api.ref("St-Patrick specials"); | |
// Now we'll use this reference for all our calls | |
Api.form('everything') | |
.ref(stPatrickRef) | |
.query(Prismic.Predicates.at("document.type", "product")).submit(function (err, response) { | |
if (err) { | |
console.log(err); | |
done(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Accessing image fields | |
var image = doc.getImage("product.image"); | |
// Most of the time you will be using the "main" view | |
var url = image.main.url; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var resolver = function (doc, isBroken) { | |
if (isBroken) return '#broken'; | |
return "/testing_url/" + doc.id + "/" + doc.slug; | |
}; | |
var source = doc.getLink("article.source"); | |
var url = source ? source.url(resolver) : null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Predicates = Prismic.Predicates; | |
// Date and Timestamp predicates | |
var dateBefore = Predicates.dateBefore("my.product.releaseDate", new Date(2014, 6, 1)); | |
var dateAfter = Predicates.dateAfter("my.product.releaseDate", new Date(2014, 1, 1)); | |
var dateBetween = Predicates.dateBetween("my.product.releaseDate", new Date(2014, 1, 1), new Date(2014, 6, 1)); | |
var dayOfMonth = Predicates.dayOfMonth("my.product.releaseDate", 14); | |
var dayOfMonthAfter = Predicates.dayOfMonthAfter("my.product.releaseDate", 14); | |
var dayOfMonthBefore = Predicates.dayOfMonthBefore("my.product.releaseDate", 14); | |
var dayOfWeek = Predicates.dayOfWeek("my.product.releaseDate", "Tuesday"); | |
var dayOfWeekAfter = Predicates.dayOfWeekAfter("my.product.releaseDate", "Wednesday"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var htmlSerializer = function (element, content) { | |
// Don't wrap images in a <p> tag | |
if (element.type == "image") { | |
return '<img src="' + element.url + '" alt="' + element.alt + '">'; | |
} | |
// Add a class to hyperlinks | |
if (element.type == "hyperlink") { | |
return '<a class="some-link" href="' + element.url + '">' + content + '</a>'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var video = doc.get("article.video"); | |
// Html is the code to include to embed the object, and depends on the embedded service | |
var html = video ? video.asHtml() : ""; |
OlderNewer