0.01
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
A Jekyll plugin for retrieving content from the Prismic.io API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 3.0.0
 Project Readme

jekyll-prismic

Install

Add the "jekyll-prismic" gem to your Gemfile:

gem "jekyll-prismic"

Then add "jekyll-prismic" to your gems in _config.yml:

gems:
    - jekyll-prismic

Configuration

prismic:
    # Your repository endpoint
    endpoint: https://lesbonneschoses.prismic.io/api
    access_token: 'Your access token if the repo is private'
    # Link resolving, key should match a document type in your repo, permalink
    # then is expanded and returned when generating the document’s URL
    links:
        post:
            permalink: /posts/:slug-:id/
    # Collections, key is used to access in the site.prismic.collections
    # template variable
    collections:
        # Example for a "posts" collection
        posts:
            # Query the documents by type (optional)
            type: post
            # Collection name (optional)
            form: posts
            # Permalink used to generate the output files. This should match an
            # entry in "links", so documents link to the right output files
            permalink: /posts/:slug-:id/
            # Layout file for this collection
            layout: prismic_post.html
            # Max quantity of items (optional, default is 20)
            page_size: 100
            # Additional queries (optional)
            query:
                - ["missing", "my.post.allow_comments"]
            # Order posts in the collection by a fragment (optional)
            orderings: '[my.post.date desc]'
            # Generate output files or not (default: false)
            output: true
            # Limit output to a number of files, useful for large collections
            # (optional)
            output_limit: nil

Usage

This plugin provides the site.prismic template variable. This template provides access to tags, bookmarks, and the collections defined in the configuration.

Using Collections

Collections are accessed by their name in site.prismic.collections. The posts collections is available at site.prismic.collections.posts.

To list all documents of the collection:

{% for post in site.prismic.collections.posts %}
<article>
    <header>
        {{ post.fragments.title.html }}
    </header>
    <div class="body">
        {{ post.fragments.body.html }}
    </div>
</article>
{% endfor %}

Using bookmarks

Prismic’s bookmarks are a handy way to load documents for things like error pages or site configuration. Bookmarks can be accessed with the site.prismic.bookmarks object. Each bookmark is returned as document, fetched from the API.

Suppose, we have an error document 404.html and a bookmark named errorpage in Prismic, our template would look this way:

---
---
{% assign document = site.prismic.bookmarks.errorpage %}

<header>{{ document.fragments.title.html }}</header>
<main>
    {{ document.fragments.body.html }}
</main>