I hereby claim:
- I am erwan on github.
- I am erwan (https://keybase.io/erwan) on keybase.
- I have a public key whose fingerprint is 2437 9A03 5B7F FE1C 3A56 6BC7 CDEA D4BA E53E 24F2
To claim this, I am signing this object:
Prismic.Api('https://lesbonneschoses.prismic.io/api', function (err, Api) { | |
Api.form('everything') | |
.ref(Api.master()) | |
.query(Prismic.Predicates.at("document.type", "product")).submit(function (err, response) { | |
if (err) { | |
console.log(err); | |
done(); | |
} | |
// The documents object contains a Response object with all documents of type "product". | |
var page = response.page; // The current page number, the first one being 1 |
I hereby claim:
To claim this, I am signing this object:
var doc = response.results[0]; | |
var html = doc.getStructuredText('blog-post.body').asHtml({ | |
linkResolver: function (ctx, doc, isBroken) { | |
if (isBroken) return '#broken'; | |
return "/testing_url/" + doc.id + "/" + doc.slug + ( ctx.maybeRef ? '?ref=' + ctx.maybeRef : '' ); | |
} | |
}); |
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>'; | |
} |
Prismic.Api('https://lesbonneschoses.prismic.io/api', function(err, Api) { | |
Api.form('everything').ref(Api.master()).query( | |
Predicates.at("document.type", "blog-post"), | |
Predicates.dateAfter("my.blog-post.date", new Date(2014, 6, 1)) | |
).submit(function(err, response) { | |
// All documents of type "product", updated after June 1st, 2014 | |
}); | |
}); |
var some test; |
val apiFuture: Future[io.prismic.Api] = Api.get("https://lesbonneschoses.prismic.io/api") | |
apiFuture.map { api => | |
println("References: " + api.refs) | |
api | |
} |
Api.get("https://lesbonneschoses.prismic.io/api").flatMap { api => | |
api.forms("everything") | |
.ref(api.master) | |
.query(Predicate.at("document.type", "product")).submit().map { response => | |
// The response object contains all documents of type "product", paginated | |
response | |
} | |
} |
Api.get("https://lesbonneschoses.prismic.io/api").flatMap { api => | |
api.forms("everything").ref(api.master).query( | |
Predicate.at("document.type", "blog-post"), | |
Predicate.dateAfter("my.blog-post.date", new DateTime(2014, 6, 1, 0, 0)) | |
).submit().map { response => | |
// All documents of type "product", updated after June 1st, 2014 | |
response | |
} | |
} |
val htmlSerializer = HtmlSerializer { | |
// Don't wrap images in a <p> tag | |
case (StructuredText.Block.Image(view, _, _), _) => s"${view.asHtml}" | |
// Add a class to em tags | |
case (em: Span.Em, content) => s"<em class='italic'>$content</em>" | |
} | |
val html = doc.getStructuredText("blog-post.body").map(_.asHtml(resolver, htmlSerializer)) |