prismicio/javascript-kit

View on GitHub
docs/index.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Home</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Home</h1>

    



    


    <h3> </h3>










    




    <section>
        <article><h2>JavaScript development kit for prismic.io</h2><p><a href="http://badge.fury.io/js/prismic.io"><img src="https://badge.fury.io/js/prismic.io.svg" alt="npm version"></a>
<a href="https://travis-ci.org/prismicio/javascript-kit"><img src="https://api.travis-ci.org/prismicio/javascript-kit.png" alt="Build Status"></a>
<a href="https://codeclimate.com/github/prismicio/javascript-kit"><img src="https://codeclimate.com/github/prismicio/javascript-kit.png" alt="Code Climate"></a>
<a href="https://codeclimate.com/github/prismicio/javascript-kit/coverage"><img src="https://codeclimate.com/github/prismicio/javascript-kit/badges/coverage.svg" alt="Test Coverage"></a></p>
<ul>
<li>The <a href="https://github.com/prismicio/javascript-kit">source code</a> is on Github.</li>
<li>The <a href="https://github.com/prismicio/javascript-kit/releases">Changelog</a> is on Github's releases tab.</li>
</ul>
<h3>Installation</h3><h4>NPM</h4><pre class="prettyprint source lang-sh"><code>npm install prismic.io --save</code></pre><h4>CDN</h4><pre class="prettyprint source"><code>https://unpkg.com/prismic.io/dist/prismic.io.min.js</code></pre><p>(You may need to adapt the version number)</p>
<h4>Downloadable version</h4><p>On our release page: <a href="https://github.com/prismicio/javascript-kit/releases">https://github.com/prismicio/javascript-kit/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 (you need a <a href="https://github.com/jakearchibald/es6-promise">Promise polyfill</a> to support IE11 and below)</li>
<li>Client-side with a simple script tag</li>
</ul>
<h3>Starter kits</h3><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>
<h3>Usage</h3><p>To fetch documents from your repository, you need to fetch the Api data first.</p>
<pre class="prettyprint source lang-javascript"><code>var Prismic = require('prismic.io');

Prismic.api(&quot;http://your_repository_name.prismic.io/api&quot;, function(error, api) {
  var options = {}; // In Node.js, pass the request as 'req' to read the reference from the cookies
  api.query(&quot;&quot;, options, function(err, response) { // An empty query will return all the documents
    if (err) {
      console.log(&quot;Something went wrong: &quot;, err);
    }
    console.log(&quot;Documents: &quot;, response.documents);
  });
});</code></pre><p>All asynchronous calls return ES2015 promises, so alternatively you can use them instead of callbacks.</p>
<pre class="prettyprint source lang-javascript"><code>var Prismic = require('prismic.io');

Prismic.api(&quot;https://lesbonneschoses.prismic.io/api&quot;).then(function(api) {
  return api.query(&quot;&quot;); // An empty query will return all the documents
}).then(function(response) {
  console.log(&quot;Documents: &quot;, response.results);
}, function(err) {
  console.log(&quot;Something went wrong: &quot;, err);
});</code></pre><p>See the <a href="https://prismic.io/docs">developer documentation</a> or the <a href="http://prismicio.github.io/javascript-kit/">API documentation</a> for more details on how to use it.</p>
<h3>Contribute to the kit</h3><p>Contribution is open to all developer levels, read our &quot;<a href="https://developers.prismic.io/documentation/UszOeAEAANUlwFpp/contribute-to-the-official-kits">Contribute to the official kits</a>&quot; documentation to learn more.</p>
<h4>Install the kit locally</h4><p>Source files are in the <code>lib/</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 class="prettyprint source"><code>npm install
npm test</code></pre><h4>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>License</h3><p>This software is licensed under the Apache 2 license, quoted below.</p>
<p>Copyright 2013-2016 Zengularity (http://www.zengularity.com).</p>
<p>Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this project except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.</p>
<p>Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; 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></article>
    </section>






</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Api.html">Api</a></li><li><a href="Doc.html">Doc</a></li><li><a href="Experiments.html">Experiments</a></li><li><a href="Fragments_Color.html">Fragments:Color</a></li><li><a href="Fragments_CompositeSlice.html">Fragments:CompositeSlice</a></li><li><a href="Fragments_Date.html">Fragments:Date</a></li><li><a href="Fragments_DocumentLink.html">Fragments:DocumentLink</a></li><li><a href="Fragments_Embed.html">Fragments:Embed</a></li><li><a href="Fragments_FileLink.html">Fragments:FileLink</a></li><li><a href="Fragments_GeoPoint.html">Fragments:GeoPoint</a></li><li><a href="Fragments_Group.html">Fragments:Group</a></li><li><a href="Fragments_ImageEl.html">Fragments:ImageEl</a></li><li><a href="Fragments_ImageLink.html">Fragments:ImageLink</a></li><li><a href="Fragments_ImageView.html">Fragments:ImageView</a></li><li><a href="Fragments_Num.html">Fragments:Num</a></li><li><a href="Fragments_Select.html">Fragments:Select</a></li><li><a href="Fragments_Separator.html">Fragments:Separator</a></li><li><a href="Fragments_SimpleSlice.html">Fragments:SimpleSlice</a></li><li><a href="Fragments_SliceZone.html">Fragments:SliceZone</a></li><li><a href="Fragments_StructuredText.html">Fragments:StructuredText</a></li><li><a href="Fragments_Text.html">Fragments:Text</a></li><li><a href="Fragments_Timestamp.html">Fragments:Timestamp</a></li><li><a href="Fragments_WebLink.html">Fragments:WebLink</a></li><li><a href="Ref.html">Ref</a></li><li><a href="Response.html">Response</a></li><li><a href="SearchForm.html">SearchForm</a></li><li><a href="WithFragments.html">WithFragments</a></li></ul><h3>Namespaces</h3><ul><li><a href="Predicates.html">Predicates</a></li></ul><h3>Global</h3><ul><li><a href="global.html#ApiCache">ApiCache</a></li><li><a href="global.html#data">data</a></li><li><a href="global.html#fragments">fragments</a></li><li><a href="global.html#insertSpans">insertSpans</a></li><li><a href="global.html#LRUCache">LRUCache</a></li><li><a href="global.html#parseDoc">parseDoc</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Mon Oct 02 2017 12:18:09 GMT+0200 (CEST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>