Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilakisfil committed Mar 4, 2015
1 parent 12e6343 commit 6fa6e02
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
38 changes: 34 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# MiddlemanPrismic

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/middleman_prismic`. To experiment with that code, run `bin/console` for an interactive prompt.

TODO: Delete this and the text above, and describe your gem

## Installation

Expand All @@ -20,9 +17,42 @@ Or install it yourself as:

$ gem install middleman_prismic

## Configuration

To configure the extension, add the following configuration block to Middleman's config.rb:


Parameter | Description
---------- |------------
api_url | the single endpoint of your content repository
access_token | Prismic API OAuth2 based access token (optional)
release | The content release (optional, defaults to `master`)
link_resolver | A link resolver. Expects a proc with one param, which is an object of type [Prismic::Fragments::DocumentLink](http://www.rubydoc.info/github/prismicio/ruby-kit/master/Prismic/Fragments/DocumentLink) (optional)

For instance:

```ruby
activate :prismic do |f|
f.api_url = 'https://testrepositorymiddleman.prismic.io/api'
f.release = 'master'
f.link_resolver = ->(link) { binding.pry; "#{link.type.pluralize}/#{link.slug}"}
f.custom_queries = { test: [Prismic::Predicates::at('document.type', 'product')] }
end
```

## Usage
Run `bundle exec middleman prismic` in your terminal. This will fetch entries for the configured
spaces and content types and put the resulting data in the [local data folder](https://middlemanapp.com/advanced/local-data/) as yaml files.

For each document mask you have, you will get a file named `prismic_{document-name}` under `/data`.
So for instance if you have article and product document masks, you will get 2 files: `prismic_articles`, `prismic_products`.
Each file will contain all your documents of the specified document mask in an array.


In your templates, you get for free helper methods named after your document mask that return the Prismic equivelant object.
For instance for articles, if you run `<%= articles %>` you get back a `Prismic::Document`.

TODO: Write usage instructions here
If at any time need access to `Prismic::Ref` you can do it using the `reference` helper.

## Development

Expand Down
2 changes: 1 addition & 1 deletion lib/middleman_prismic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def initialize(app, options_hash={}, &block)
helpers do
Dir["data/prismic_*"].each do |file|
define_method(file.gsub('data/prismic_','')) do
YAML::load(File.read(file))
YAML::load(File.read(file)).values
end
end

Expand Down

0 comments on commit 6fa6e02

Please sign in to comment.