prismic-javascript
Version:
JavaScript development kit for prismic.io
721 lines (710 loc) • 40.8 kB
HTML
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>prismic-javascript</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="assets/css/main.css">
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="assets/js/search.js" data-base=".">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="index.html" class="title">prismic-javascript</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
<input type="checkbox" id="tsd-filter-externals" checked />
<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
<input type="checkbox" id="tsd-filter-only-exported" />
<label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<ul class="tsd-breadcrumb">
<li>
<a href="globals.html">Globals</a>
</li>
</ul>
<h1> prismic-javascript</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<div class="tsd-panel tsd-typography">
<h2 id="javascript-development-for-prismic-io-api-v2">JavaScript development for prismic.io API v2</h2>
<p><a href="http://badge.fury.io/js/prismic-javascript"><img src="https://badge.fury.io/js/prismic-javascript.svg" alt="npm version"></a>
<a href="https://travis-ci.org/prismicio/prismic-javascript"><img src="https://api.travis-ci.org/prismicio/prismic-javascript.png" alt="Build Status"></a></p>
<ul>
<li>The <a href="https://github.com/prismicio/prismic-javascript">source code</a> is on Github.</li>
<li>The <a href="https://github.com/prismicio/prismic-javascript/releases">Changelog</a> is on Github's releases tab.</li>
<li>The <a href="https://prismicio.github.io/prismic-javascript/globals.html">API reference</a> is on Github.</li>
</ul>
<p>It's meant to work in pair with the prismic-dom library available here:</p>
<ul>
<li><a href="https://github.com/prismicio/prismic-dom">prismic-dom</a> is on Github.</li>
</ul>
<hr>
<h2 id="1-installation"><a href="#installation">1. Installation</a></h2>
<blockquote>
<p><a href="#prismic-api-settings">Prismic API Settings</a> <br />
<a href="#npm">NPM</a> <br />
<a href="#cdn">CDN</a> <br />
<a href="#downloadable-version">Downloadable version</a> <br />
<a href="#demo-project">Demo project</a> <br />
<a href="#starter-kits">Starter kits</a> <br /></p>
</blockquote>
<h2 id="2-query-the-content"><a href="#query-the-content">2. Query the content</a></h2>
<h2 id="3-integrate-the-content"><a href="#integrate-the-content">3. Integrate the content</a></h2>
<blockquote>
<p><a href="#embed">Embed</a> <br />
<a href="#image">Image</a> <br />
<a href="#text">Text</a> <br />
<a href="#number">Number</a> <br />
<a href="#date">Date</a> <br />
<a href="#timestamp">Timestamp</a> <br />
<a href="#select">Select</a> <br />
<a href="#color">Color</a> <br />
<a href="#structuredText">StructuredText</a> <br />
<a href="#weblink">WebLink</a> <br />
<a href="#documentlink">DocumentLink</a> <br />
<a href="#imagelink">ImageLink</a> <br />
<a href="#filelink">FileLink</a> <br />
<a href="#separator">Separator</a> <br />
<a href="#group">Group</a> <br />
<a href="#geopoint">GeoPoint</a> <br />
<a href="#slices">Slices</a> <br /></p>
</blockquote>
<h2 id="4-contribute-to-the-kit"><a href="#contribute-to-the-kit">4. Contribute to the kit</a></h2>
<blockquote>
<p><a href="#install-the-kit-locally">Install the kit locally</a> <br />
<a href="#documentation">Documentation</a> <br /></p>
</blockquote>
<h2 id="5-license"><a href="#license">5. License</a></h2>
<hr>
<h3 id="installation">Installation</h3>
<h4 id="prismic-api-settings">Prismic API Settings</h4>
<p>Your endpoint must contains "v2" at the end, otherwise it means that you're working on the API V1 so this library won't work for you.</p>
<pre><code class="language-javascript">apiEndpoint: your-repo-name.prismic.io/api/v2</code></pre>
<h4 id="npm">NPM</h4>
<pre><code class="language-sh">npm install prismic-javascript --save</code></pre>
<h4 id="cdn">CDN</h4>
<pre><code><span class="hljs-symbol">https:</span><span class="hljs-comment">//unpkg.com/prismic-javascript</span></code></pre><p>(You may need to adapt the version number)</p>
<h4 id="downloadable-version">Downloadable version</h4>
<p>On our release page: <a href="https://github.com/prismicio/prismic-javascript/releases">https://github.com/prismicio/prismic-javascript/releases</a>.</p>
<p>The kit is universal, it can be used:</p>
<ul>
<li>Server-side with NodeJS</li>
<li>Client-side as part of your build with Browserify, Webpack</li>
<li>Client-side with a simple script tag</li>
</ul>
<h4 id="starter-kits">Starter kits</h4>
<p>For new project, you can start from a sample project:</p>
<ul>
<li><a href="https://github.com/prismicio/nodejs-sdk">Node.js project</a></li>
<li><a href="https://github.com/prismicio/nodejs-blog">Node.js blog</a></li>
</ul>
<h4 id="demo-project">Demo project</h4>
<p>You can find an integration of prismic content with the new API V2 in the following project:</p>
<ul>
<li><a href="https://github.com/arnaudlewis/prismic-apiv2">Node.js project</a></li>
</ul>
<h3 id="query-the-content">Query the content</h3>
<p>To fetch documents from your repository, you need to fetch the Api data first.</p>
<pre><code class="language-javascript"><span class="hljs-keyword">var</span> Prismic = <span class="hljs-built_in">require</span>(<span class="hljs-string">'prismic-javascript'</span>);
Prismic.api(<span class="hljs-string">"http://your_repository_name.prismic.io/api"</span>, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">error, api</span>) </span>{
<span class="hljs-keyword">var</span> options = {}; <span class="hljs-comment">// In Node.js, pass the request as 'req' to read the reference from the cookies</span>
api.query(<span class="hljs-string">""</span>, options, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err, response</span>) </span>{ <span class="hljs-comment">// An empty query will return all the documents</span>
<span class="hljs-keyword">if</span> (err) {
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Something went wrong: "</span>, err);
}
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Documents: "</span>, response.documents);
});
});</code></pre>
<p>All asynchronous calls return ES2015 promises, so alternatively you can use them instead of callbacks.</p>
<pre><code class="language-javascript"><span class="hljs-keyword">var</span> Prismic = <span class="hljs-built_in">require</span>(<span class="hljs-string">'prismic-javascript'</span>);
Prismic.api(<span class="hljs-string">"https://your-repository-name.prismic.io/api"</span>).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">api</span>) </span>{
<span class="hljs-keyword">return</span> api.query(<span class="hljs-string">""</span>); <span class="hljs-comment">// An empty query will return all the documents</span>
}).then(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">response</span>) </span>{
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Documents: "</span>, response.results);
}, <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">err</span>) </span>{
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Something went wrong: "</span>, err);
});</code></pre>
<p>If you included prismic through the script tag (CDN) there is a global variable PrismicJS: </p>
<pre><code class="language-javascript">PrismicJS.api(<span class="hljs-string">"https://your-repository-name.prismic.io/api"</span>).then( <span class="hljs-function"><span class="hljs-params">api</span> =></span> {
<span class="hljs-keyword">const</span> faq = PrismicJS.Predicates.at(<span class="hljs-string">'document.type'</span>, <span class="hljs-string">'faq'</span>);
api.query(faq, { <span class="hljs-attr">lang</span>: <span class="hljs-string">'en-en'</span> }).then( <span class="hljs-function"><span class="hljs-params">response</span> =></span> {
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Documents: "</span>, response.results);
})
})</code></pre>
<p>See the <a href="https://prismic.io/docs">developer documentation</a> or the <a href="https://prismicio.github.io/prismic-javascript/globals.html">API documentation</a> for more details on how to use it.</p>
<h3 id="integrate-the-content">Integrate the content</h3>
<p>In each case documented below, you will have a snippet of the custom type and another for the code needed to fill the content field into your JS Template.
In these examples we have a <code>doc</code> parameter corresponding to the fetched prismic document.</p>
<h4 id="embed">Embed</h4>
<p>Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"video"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Embed"</span>
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript">doc.data.video.embed_url</code></pre>
<h4 id="image">Image</h4>
<p>Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"photo"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Image"</span>,
<span class="hljs-string">"fieldset"</span> : <span class="hljs-string">"Image"</span>,
<span class="hljs-string">"config"</span> : {
<span class="hljs-string">"constraint"</span> : {
<span class="hljs-string">"width"</span> : <span class="hljs-number">300</span>,
<span class="hljs-string">"height"</span> : <span class="hljs-number">300</span>
},
<span class="hljs-string">"thumbnails"</span> : [ {
<span class="hljs-string">"name"</span> : <span class="hljs-string">"Small"</span>,
<span class="hljs-string">"width"</span> : <span class="hljs-number">100</span>,
<span class="hljs-string">"height"</span> : <span class="hljs-number">100</span>
}, {
<span class="hljs-string">"name"</span> : <span class="hljs-string">"Medium"</span>,
<span class="hljs-string">"width"</span> : <span class="hljs-number">200</span>,
<span class="hljs-string">"height"</span> : <span class="hljs-number">200</span>
}, {
<span class="hljs-string">"name"</span> : <span class="hljs-string">"Large"</span>,
<span class="hljs-string">"width"</span> : <span class="hljs-number">300</span>,
<span class="hljs-string">"height"</span> : <span class="hljs-number">300</span>
} ]
}
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript"><span class="hljs-comment">//main view</span>
doc.data.photo.url
doc.data.photo.alt
doc.data.photo.width
doc.data.photo.height
<span class="hljs-comment">//thumbnails => example for small view</span>
doc.data.photo.small.url
doc.data.photo.small.alt
doc.data.photo.small.width
doc.data.photo.small.height</code></pre>
<h4 id="text">Text</h4>
<p>Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"title"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Text"</span>,
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript">doc.data.title</code></pre>
<h4 id="number">Number</h4>
<p>Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"count"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Text"</span>,
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript">doc.data.count</code></pre>
<h4 id="date">Date</h4>
<p>Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"publication"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Date"</span>,
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript"><span class="hljs-keyword">import</span> { <span class="hljs-built_in">Date</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">'prismic-dom'</span>
<span class="hljs-comment">// date as string from the API</span>
doc.data.publication
<span class="hljs-comment">// date as JS Date</span>
<span class="hljs-built_in">Date</span>(doc.data.publication)
</code></pre>
<h4 id="timestamp">Timestamp</h4>
<p>Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"time"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Timestamp"</span>,
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript"><span class="hljs-keyword">import</span> { <span class="hljs-built_in">Date</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">'prismic-dom'</span>
<span class="hljs-comment">// timestamp as string from the API</span>
doc.data.time
<span class="hljs-comment">// timestamp as JS Datetime</span>
<span class="hljs-built_in">Date</span>(doc.data.time)</code></pre>
<h4 id="select">Select</h4>
<p>Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"gender"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Select"</span>,
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript">doc.data.gender</code></pre>
<h4 id="color">Color</h4>
<p>Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"background"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Color"</span>,
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript">doc.data.background</code></pre>
<h4 id="richtext">RichText</h4>
<p>Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"description"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"StructuredText"</span>,
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript"><span class="hljs-keyword">import</span> { RichText } <span class="hljs-keyword">from</span> <span class="hljs-string">'prismic-dom'</span>
RichText.asText(doc.data.description)
<span class="hljs-comment">//linkResolver must be declare somewhere</span>
RichText.asHtml(doc.data.description, linkResolver)</code></pre>
<h4 id="weblink">WebLink</h4>
<p>Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"linktoweb"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Link"</span>,
<span class="hljs-string">"config"</span> : {
<span class="hljs-string">"select"</span> : <span class="hljs-string">"web"</span>
}
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript">doc.data.linktoweb.url</code></pre>
<h4 id="documentlink">DocumentLink</h4>
<p>Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"linktodoc"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Link"</span>,
<span class="hljs-string">"config"</span> : {
<span class="hljs-string">"select"</span> : <span class="hljs-string">"document"</span>,
<span class="hljs-string">"customtypes"</span> : [ <your-custom-type-id> ],
"tags" : [ <your-tag> ],
}
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript"><span class="hljs-comment">//return url of the document link</span>
doc.data.linktodoc
<span class="hljs-comment">//return url of the document</span>
linkResolver(doc.data.linktodoc)</code></pre>
<h4 id="imagelink">ImageLink</h4>
<p>Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"linktomedia"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Link"</span>,
<span class="hljs-string">"config"</span> : {
<span class="hljs-string">"select"</span> : <span class="hljs-string">"media"</span>
}
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript">doc.data.linktomedia.url</code></pre>
<h4 id="filelink">FileLink</h4>
<p>Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"linktofile"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Link"</span>,
<span class="hljs-string">"config"</span> : {
<span class="hljs-string">"select"</span> : <span class="hljs-string">"media"</span>
}
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript">doc.data.linktofile.url</code></pre>
<h4 id="group">Group</h4>
<p>Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"feature"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Group"</span>,
<span class="hljs-string">"repeat"</span>: <span class="hljs-literal">true</span>, <span class="hljs-comment">//default to true but put explicitly for the example</span>
<span class="hljs-string">"config"</span> : {
<span class="hljs-string">"field"</span> : {
<span class="hljs-string">"title"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Text"</span>,
},
<span class="hljs-string">"description"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"StructuredText"</span>,
}
}
}
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript"><span class="hljs-keyword">import</span> { RichText } <span class="hljs-keyword">from</span> <span class="hljs-string">'prismic-dom'</span>
doc.data.feature.forEach(<span class="hljs-function"><span class="hljs-params">item</span> =></span> {
item.title
RichText.asHtml(item.description, linkResolver)
})</code></pre>
<h4 id="geopoint">GeoPoint</h4>
<p>Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"location"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"GeoPoint"</span>,
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript">doc.data.latitude
doc.data.longitude</code></pre>
<h4 id="slices">Slices</h4>
<p><strong>Slice with Group as value</strong>
The Group value will be put directly as Slice value
Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"contentAsSlices"</span> : {
<span class="hljs-string">"fieldset"</span> : <span class="hljs-string">"Dynamic page zone..."</span>,
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Slices"</span>,
<span class="hljs-string">"config"</span> : {
<span class="hljs-string">"choices"</span> : {
<span class="hljs-string">"slides"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Group"</span>,
<span class="hljs-comment">//required to display name in slice select in the writing room</span>
<span class="hljs-string">"fieldset"</span> : <span class="hljs-string">"Slides"</span>,
<span class="hljs-string">"config"</span> : {
<span class="hljs-string">"fields"</span> : {
<span class="hljs-string">"illustration"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Image"</span>
},
<span class="hljs-string">"title"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"StructuredText"</span>
}
}
}
}
}
}
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript"><span class="hljs-keyword">for</span>(slice <span class="hljs-keyword">in</span> doc.data.contentAsSlices) {
<span class="hljs-keyword">switch</span>(slice.slice_type) {
<span class="hljs-keyword">case</span> <span class="hljs-string">'slides'</span>:
slice.value.forEach(<span class="hljs-function"><span class="hljs-params">item</span> =></span> {
item.illustration.url
item.title
})
<span class="hljs-keyword">break</span>
}
}
</code></pre>
<p><strong>Slice with basic fragment like Text as value</strong>
The fragment value will be put directly as Slice value
Custom type</p>
<pre><code class="language-javascript"><span class="hljs-string">"contentAsSlices"</span> : {
<span class="hljs-string">"fieldset"</span> : <span class="hljs-string">"Dynamic page zone..."</span>,
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Slices"</span>,
<span class="hljs-string">"config"</span> : {
<span class="hljs-string">"choices"</span> : {
<span class="hljs-string">"description"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"StructuredText"</span>
}
}
}
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript"><span class="hljs-keyword">import</span> { RichText } <span class="hljs-keyword">from</span> <span class="hljs-string">'prismic-dom'</span>
<span class="hljs-keyword">for</span>(slice <span class="hljs-keyword">in</span> doc.contentAsSlices) {
<span class="hljs-keyword">switch</span>(slice.slice_type) {
<span class="hljs-keyword">case</span> <span class="hljs-string">'description'</span>:
RichText.asHtml(slice.value, linkResolver)
<span class="hljs-keyword">break</span>
}
}
</code></pre>
<p><strong>new Slice</strong>
the new Slice type allow you to create a repeatable area and a non repeatable one.</p>
<pre><code class="language-javascript"><span class="hljs-string">"contentAsSlices"</span> : {
<span class="hljs-string">"fieldset"</span> : <span class="hljs-string">"Dynamic page zone..."</span>,
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Slices"</span>,
<span class="hljs-string">"config"</span> : {
<span class="hljs-string">"choices"</span> : {
<span class="hljs-string">"newslice"</span> : {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"Slice"</span>,
<span class="hljs-string">"non-repeat"</span>: {
<span class="hljs-string">"title"</span>: {
<span class="hljs-string">"type"</span>: <span class="hljs-string">"Text"</span>
}
},
<span class="hljs-string">"repeat"</span>: {
<span class="hljs-string">"description"</span>: {
<span class="hljs-string">"type"</span> : <span class="hljs-string">"StructuredText"</span>
}
}
}
}
}
}</code></pre>
<p>Template JS</p>
<pre><code class="language-javascript"><span class="hljs-keyword">import</span> { RichText } <span class="hljs-keyword">from</span> <span class="hljs-string">'prismic-dom'</span>
<span class="hljs-keyword">for</span>(slice <span class="hljs-keyword">in</span> doc.contentAsSlices) {
<span class="hljs-keyword">switch</span>(slice.slice_type) {
<span class="hljs-keyword">case</span> <span class="hljs-string">'newslice'</span>:
<span class="hljs-comment">//non repeatable part</span>
slice.value.primary.title
<span class="hljs-comment">//repeatable part</span>
slice.value.items.forEach(<span class="hljs-function"><span class="hljs-params">item</span> =></span> {
RichText.asHtml(item.description, linkResolver)
})
<span class="hljs-keyword">break</span>
}
}
</code></pre>
<h3 id="contribute-to-the-kit">Contribute to the kit</h3>
<h4 id="install-the-kit-locally">Install the kit locally</h4>
<p>Source files are in the <code>src/</code> directory. You only need <a href="http://www.joyent.com/blog/installing-node-and-npm/">Node.js and npm</a>
to work on the codebase.</p>
<pre><code class="language-bash">npm install
npm run dev</code></pre>
<h4 id="documentation">Documentation</h4>
<p>Please document any new feature or bugfix using the <a href="http://usejsdoc.org/">JSDoc</a> syntax. You don't need to generate the documentation, we'll do that.</p>
<p>If you feel an existing area of code is lacking documentation, feel free to write it; but please do so on its own branch and pull-request.</p>
<p>If you find existing code that is not optimally documented and wish to make it better, we really appreciate it; but you should document it on its own branch and its own pull request.</p>
<h3 id="license">License</h3>
<p>This software is licensed under the Apache 2 license, quoted below.</p>
<p>Copyright 2013-2017 Prismic.io (<a href="http://prismic.io)">http://prismic.io)</a>.</p>
<p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>.</p>
<p>Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.</p>
</div>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class="globals ">
<a href="globals.html"><em>Globals</em></a>
</li>
<li class=" tsd-kind-module">
<a href="modules/prismic.html">Prismic</a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
<li class=" tsd-kind-class tsd-is-external">
<a href="classes/api.html" class="tsd-kind-icon">Api</a>
</li>
<li class=" tsd-kind-class tsd-is-external">
<a href="classes/defaultapicache.html" class="tsd-kind-icon">Default<wbr>Api<wbr>Cache</a>
</li>
<li class=" tsd-kind-class tsd-is-external">
<a href="classes/defaultclient.html" class="tsd-kind-icon">Default<wbr>Client</a>
</li>
<li class=" tsd-kind-class tsd-is-external">
<a href="classes/defaultrequesthandler.html" class="tsd-kind-icon">Default<wbr>Request<wbr>Handler</a>
</li>
<li class=" tsd-kind-class tsd-is-external">
<a href="classes/experiment.html" class="tsd-kind-icon">Experiment</a>
</li>
<li class=" tsd-kind-class tsd-is-external">
<a href="classes/experiments.html" class="tsd-kind-icon">Experiments</a>
</li>
<li class=" tsd-kind-class tsd-is-external">
<a href="classes/httpclient.html" class="tsd-kind-icon">Http<wbr>Client</a>
</li>
<li class=" tsd-kind-class tsd-is-external">
<a href="classes/lazysearchform.html" class="tsd-kind-icon">Lazy<wbr>Search<wbr>Form</a>
</li>
<li class=" tsd-kind-class tsd-is-external">
<a href="classes/resolvedapi.html" class="tsd-kind-icon">Resolved<wbr>Api</a>
</li>
<li class=" tsd-kind-class tsd-is-external">
<a href="classes/searchform.html" class="tsd-kind-icon">Search<wbr>Form</a>
</li>
<li class=" tsd-kind-class tsd-is-external">
<a href="classes/variation.html" class="tsd-kind-icon">Variation</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/alternatelanguage.html" class="tsd-kind-icon">Alternate<wbr>Language</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/apicache.html" class="tsd-kind-icon">Api<wbr>Cache</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/apidata.html" class="tsd-kind-icon">Api<wbr>Data</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/apioptions.html" class="tsd-kind-icon">Api<wbr>Options</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/apisearchresponse.html" class="tsd-kind-icon">Api<wbr>Search<wbr>Response</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/client.html" class="tsd-kind-icon">Client</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/cookie.html" class="tsd-kind-icon">Cookie</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/document.html" class="tsd-kind-icon">Document</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/form.html" class="tsd-kind-icon">Form</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/httpclientoptions.html" class="tsd-kind-icon">Http<wbr>Client<wbr>Options</a>
</li>
<li class=" tsd-kind-interface tsd-is-external tsd-is-not-exported">
<a href="interfaces/ientry.html" class="tsd-kind-icon">IEntry</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/ilrucache.html" class="tsd-kind-icon">ILRUCache</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/language.html" class="tsd-kind-icon">Language</a>
</li>
<li class=" tsd-kind-interface tsd-is-external tsd-is-not-exported">
<a href="interfaces/noderequestinit.html" class="tsd-kind-icon">Node<wbr>Request<wbr>Init</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/previewresolver.html" class="tsd-kind-icon">Preview<wbr>Resolver</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/previewresponse.html" class="tsd-kind-icon">Preview<wbr>Response</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/queryoptions.html" class="tsd-kind-icon">Query<wbr>Options</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/ref.html" class="tsd-kind-icon">Ref</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/requesthandler.html" class="tsd-kind-icon">Request<wbr>Handler</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/requesthandleroption.html" class="tsd-kind-icon">Request<wbr>Handler<wbr>Option</a>
</li>
<li class=" tsd-kind-interface tsd-is-external">
<a href="interfaces/resolvedapioptions.html" class="tsd-kind-icon">Resolved<wbr>Api<wbr>Options</a>
</li>
<li class=" tsd-kind-type-alias tsd-is-external">
<a href="globals.html#fields" class="tsd-kind-icon">Fields</a>
</li>
<li class=" tsd-kind-type-alias tsd-is-external">
<a href="globals.html#linkresolver" class="tsd-kind-icon">Link<wbr>Resolver</a>
</li>
<li class=" tsd-kind-type-alias tsd-is-external tsd-is-not-exported">
<a href="globals.html#predicatevalue" class="tsd-kind-icon">Predicate<wbr>Value</a>
</li>
<li class=" tsd-kind-type-alias tsd-has-type-parameter tsd-is-external">
<a href="globals.html#requestcallback" class="tsd-kind-icon">Request<wbr>Callback</a>
</li>
<li class=" tsd-kind-variable tsd-is-external">
<a href="globals.html#experiment_cookie" class="tsd-kind-icon">EXPERIMENT_<wbr>COOKIE</a>
</li>
<li class=" tsd-kind-variable tsd-is-external">
<a href="globals.html#preview_cookie" class="tsd-kind-icon">PREVIEW_<wbr>COOKIE</a>
</li>
<li class=" tsd-kind-variable tsd-is-external tsd-is-not-exported">
<a href="globals.html#decode" class="tsd-kind-icon">decode</a>
</li>
<li class=" tsd-kind-function tsd-is-external tsd-is-not-exported">
<a href="globals.html#lrucache" class="tsd-kind-icon">LRUCache</a>
</li>
<li class=" tsd-kind-function tsd-is-external">
<a href="globals.html#makelrucache" class="tsd-kind-icon">MakeLRUCache</a>
</li>
<li class=" tsd-kind-function tsd-is-external">
<a href="globals.html#createpreviewresolver" class="tsd-kind-icon">create<wbr>Preview<wbr>Resolver</a>
</li>
<li class=" tsd-kind-function tsd-is-external tsd-is-not-exported">
<a href="globals.html#encode" class="tsd-kind-icon">encode</a>
</li>
<li class=" tsd-kind-function tsd-has-type-parameter tsd-is-external tsd-is-not-exported">
<a href="globals.html#fetchrequest" class="tsd-kind-icon">fetch<wbr>Request</a>
</li>
<li class=" tsd-kind-function tsd-is-external tsd-is-not-exported">
<a href="globals.html#parse" class="tsd-kind-icon">parse</a>
</li>
<li class=" tsd-kind-function tsd-is-external tsd-is-not-exported">
<a href="globals.html#separator" class="tsd-kind-icon">separator</a>
</li>
<li class=" tsd-kind-function tsd-is-external tsd-is-not-exported">
<a href="globals.html#trydecode" class="tsd-kind-icon">try<wbr>Decode</a>
</li>
<li class=" tsd-kind-object-literal tsd-is-external tsd-is-not-exported">
<a href="globals.html#operator" class="tsd-kind-icon">OPERATOR</a>
</li>
<li class=" tsd-kind-object-literal tsd-is-external tsd-is-not-exported">
<a href="globals.html#date" class="tsd-kind-icon">date</a>
</li>
<li class=" tsd-kind-object-literal tsd-is-external tsd-is-not-exported">
<a href="globals.html#geopoint" class="tsd-kind-icon">geopoint</a>
</li>
<li class=" tsd-kind-object-literal tsd-is-external tsd-is-not-exported">
<a href="globals.html#number" class="tsd-kind-icon">number</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-module"><span class="tsd-kind-icon">Module</span></li>
<li class="tsd-kind-object-literal"><span class="tsd-kind-icon">Object literal</span></li>
<li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li>
<li class="tsd-kind-function"><span class="tsd-kind-icon">Function</span></li>
<li class="tsd-kind-function tsd-has-type-parameter"><span class="tsd-kind-icon">Function with type parameter</span></li>
<li class="tsd-kind-index-signature"><span class="tsd-kind-icon">Index signature</span></li>
<li class="tsd-kind-type-alias"><span class="tsd-kind-icon">Type alias</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-enum"><span class="tsd-kind-icon">Enumeration</span></li>
<li class="tsd-kind-enum-member"><span class="tsd-kind-icon">Enumeration member</span></li>
<li class="tsd-kind-property tsd-parent-kind-enum"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-enum"><span class="tsd-kind-icon">Method</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-interface"><span class="tsd-kind-icon">Interface</span></li>
<li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li>
<li class="tsd-kind-constructor tsd-parent-kind-interface"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li>
<li class="tsd-kind-index-signature tsd-parent-kind-interface"><span class="tsd-kind-icon">Index signature</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li>
<li class="tsd-kind-class tsd-has-type-parameter"><span class="tsd-kind-icon">Class with type parameter</span></li>
<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class"><span class="tsd-kind-icon">Accessor</span></li>
<li class="tsd-kind-index-signature tsd-parent-kind-class"><span class="tsd-kind-icon">Index signature</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private method</span></li>
<li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-private"><span class="tsd-kind-icon">Private accessor</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static property</span></li>
<li class="tsd-kind-call-signature tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="http://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="assets/js/main.js"></script>
<script>if (location.protocol == 'file:') document.write('<script src="assets/js/search.js"><' + '/script>');</script>
</body>
</html>