Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Paginating data in multiple yaml files using Contentful #15

Open
olliekav opened this issue Jan 6, 2017 · 4 comments
Open

Paginating data in multiple yaml files using Contentful #15

olliekav opened this issue Jan 6, 2017 · 4 comments

Comments

@olliekav
Copy link

olliekav commented Jan 6, 2017

I'm trying to paginate data brought in from Contentful, but struggling with the following error..

middleman-pagination-86aa6efd5409/lib/middleman/pagination/index_path.rb:41:in 'index_file_pattern': undefined method 'index_file' for #<Middleman::Application:0x70303404706160> (NoMethodError)

My set up is as follows...

- config.rb

app.data.blog.articles.each do |article|
  proxy "/blog/#{article[1][:slug]}/index.html", "/blog/show.html", locals: { 
    article: article[1]
  }, :ignore => true
end

activate :pagination do
  pageable_set :articles do
    data.blog.articles.sort_by{ |id,a| a[:date] }.reverse
  end
end

- /blog/index.html.erb

---
pagination:
  for: articles
  per_page: 10
---

<% content_for(:title, "Blog") %>

<section class="blog">

  <header class="section-header">
    <h1>Our Blog</h1>  
  </header>

  <div class="blog-list">
    
    <% pagination.each do |article| %>
      <%= partial "blog_summary", :locals => { :article => article } %>
    <% end %>

  </div>

</section>

Then my blog files are stored as...

  • data
    -- blog
    ---articles
    ---- 1DYb43fjkefef34U.yaml
    etc
    etc
@macandcheese
Copy link

@olliekav I'm running into the same exact issue with data from Contentful. Were you able to figure out a solution?

@andrezimpel
Copy link

+1

@Wooobee
Copy link

Wooobee commented Jan 26, 2018

Don't know if it still helps. This is a quick and dirty workaround:

data.contentful.blog.each do |elem|
  posts.push(elem[1])
end

activate :pagination do
  pageable_set :posts do
    posts
  end
end

Best Manuel

@olliekav
Copy link
Author

@Wooobee Nice, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants