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
class StarterKitLinkResolver extends LinkResolver | |
{ | |
// [...] | |
public function resolve($link) | |
{ | |
// [...] | |
if ($link->getType() == 'author') { | |
return '/author/'.$link->getId().'/'.$link->getSlug(); | |
} | |
if ($link->getType() == 'category') { |
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
// This goes to the app/app.php file, before the "page" route to take priority | |
// Let's add a route for our event type | |
$app->get('/event/:uid', function ($uid) use($app, $prismic) { | |
$doc = $prismic->by_uid('event', $uid); | |
if (!$doc) { | |
not_found($app); | |
return; | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title><?= single_post_title() ?> <?= site_title() ?></title> | |
<link rel="stylesheet" href="/assets/reset.css"> | |
<link rel="stylesheet" href="/assets/common.css"> | |
<link rel="stylesheet" href="/assets/main.css"> | |
<link rel="stylesheet" href="/assets/blog.css"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
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
{ | |
"Happening" : { | |
"title" : { | |
"fieldset" : "Event title", | |
"type" : "StructuredText", | |
"config" : { | |
"single" : "heading1,em,strong", | |
"placeholder" : "What is your event called?" | |
} | |
}, |
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
resolver = Prismic.link_resolver('master'){ |doc_link| "http:#localhost/#{doc_link.id}" } | |
doc = response.results[0] | |
html = doc['blog-post.body'].as_html(resolver) |
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
resolver = Prismic.link_resolver('master'){ |doc_link| "http:#localhost/#{doc_link.id}" } | |
serializer = Prismic.html_serializer do |element, html| | |
if element.is_a?(Prismic::Fragments::StructuredText::Block::Image) | |
# Don't wrap images in a <p> tag | |
%(<img src="#{element.url}" alt="#{element.alt}" width="#{element.width}" height="#{element.height}" />) | |
else | |
nil | |
end | |
end | |
doc = response.results[0] |
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
# You can pass any object implementing the same methods as the BasicCache | |
# https://github.com/prismicio/ruby-kit/blob/master/lib/prismic/cache/basic.rb | |
cache = Prismic::BasicCache.new | |
api = Prismic::api('https://lesbonneschoses.cdn.prismic.io/api', { :cache => cache }) | |
# The Api will use the custom cache object |
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 | |
image = doc.get_image('product.image') | |
# Most of the time you will be using the "main" view | |
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
# "near" predicate for GeoPoint fragments | |
near = Predicates::near('my.store.location', 48.8768767, 2.3338802, 10) | |
# Accessing GeoPoint fragments | |
place = document.get_geopoint('article.location') | |
coordinates = place ? (place.latitude.to_s + ',' + place.longitude.to_s) : '' |
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
bgcolor = document.get_color('article.background') | |
hex = '#' + (bgcolor ? bgcolor.value : 'FFFFFF') |
NewerOlder