jekyll-prismic icon indicating copy to clipboard operation
jekyll-prismic copied to clipboard

Not able to render posts or Drops

Open allizad opened this issue 6 years ago • 0 comments

I have my config set up similarly to the README:

prismic:
  endpoint: https://NAME.cdn.prismic.io/api
  links:
    post:
      permalink: /blog/:slug/
  collections:
    posts:
      type: post
      form: posts
      permalink: /blog/:slug
      layout: prismic_post.html
      orderings: '[post.date desc]'
      output: true

I use Jekyll 3.8, so I had to update the dependency locally:

gemspec:

  spec.add_runtime_dependency("prismic.io", "~> 1.2")
  spec.add_runtime_dependency("jekyll", "~> 3.8.0")

if I run the build, I get this error:

Liquid Exception: undefined method `to_liquid' for #<Prismic::Document:0x007fe148965560> in posts/a-week-in-oijoij-SLUG.html
/Users/allisonzadrozny/.rvm/gems/ruby-2.3.3/gems/liquid-4.0.0/lib/liquid/variable_lookup.rb:49:in `block in evaluate': undefined method `to_liquid' for #<Prismic::Document:0x007fe148965560> (NoMethodError)

If I edit the generator PrismicPage initialize method like blow, when running build it works:

  parsed_document = {};
        parsed_document["title"] = document.fragments["title"].as_html(true)
        parsed_document["featured_image"] = document.fragments["featured_image"].url
        parsed_document["content"] = document.fragments["content"].as_html(true)

        self.data['document'] = document

I believe that Drops aren't working as expected. When trying to iterate over my collection information like so:

{% for post in site.prismic.collections.posts %}
      {{ post.fragments. }}
    {% endfor %}

I get this error:

Source: src
       Destination: public
 Incremental build: enabled
      Generating... 
  Liquid Exception: stack level too deep in /_layouts/blog.html
/Users/allisonzadrozny/code/open-source/jekyll-prismic/lib/jekyll/prismic/site.rb:14:in `prismic_collections': stack level too deep (SystemStackError)
	from /Users/allisonzadrozny/code/open-source/jekyll-prismic/lib/jekyll/prismic/drops.rb:206:in `collections'
	from /Users/allisonzadrozny/.rvm/gems/ruby-2.3.3/gems/liquid-4.0.0/lib/liquid/drop.rb:35:in `invoke_drop'

Is this perhaps a version thing with Liquid and this plugin and updated Jekyll locally to 3.8? I'd really like to use this plugin on 3.8. Any advice for debugging this would be greatly appreciated — thanks!

allizad avatar Sep 06 '18 06:09 allizad