Giter Site home page Giter Site logo

angular-prismicio's Introduction

angular-prismicio

Build Status Analytics

AngularJS service for prismic.io.

How do I add this to my project?

You can download it manually by clicking here to download development unminified version or here to download minified production version

Dependencies

Usage instructions

First you need to configure the PrismicProvider. You can configure the following parameters where the API Endpoint is mandatory.

  • API Endpoint (setApiEndpoint)
  • Access token if the Master is not open (setAccessToken)
  • OAuth (setClientId, setClientSecret)
  • Links resolution rules (setLinkResolver)

You can configure the PrismicProvider in the config

var app = angular.module('app', ['prismic.io']);

app.config(function(PrismicProvider) {
    PrismicProvider.setApiEndpoint('https://lesbonneschoses.prismic.io/api');
    PrismicProvider.setAccessToken('');
    PrismicProvider.setClientId('');
    PrismicProvider.setClientSecret('');
    PrismicProvider.setLinkResolver(function(ctx, doc) {
        return 'detail.html?id=' + doc.id + '&slug=' + doc.slug + ctx.maybeRefParam;
    });
});

As soon as the above is done you are ready to inject PrismicProvider in your services and controllers:

app.controller('AppCtrl', ['Prismic', function(Prismic) {
    var self = this;
    Prismic.all().then(function(data) {
        self.data = data;
    });
}]);

Documentation

These are the methods that can be called on the Prismic object:

  • Prismic.all()
  • Prismic.query(predicateBasedQueryString)
  • Prismic.document(idString)
  • Prismic.documents(idsArray)
  • Prismic.bookmark(bookmarkString)

Or for more advanced queries using the underlying objects of the JS kit:

  • Prismic.api()
  • Prismic.ctx()

The prismicHtml-directive can be used as follows

<prismic-html fragment="data.fragment"></prismic-html>

where 'fragment' is a prismic.io type/value object.

Contributting

New contributions are always welcomed. Just open a pull request making sure that it contains tests and documentation updates.

License

MIT

angular-prismicio's People

Contributors

rudyrigot avatar dlecan avatar ghelton avatar paul-psdigital avatar karmats avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.