Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

octopress-multilingual with octopress-paginate are not compatible with latest jekyll #42

Open
ccamacho opened this issue Sep 7, 2017 · 0 comments

Comments

@ccamacho
Copy link

ccamacho commented Sep 7, 2017

I'm trying to integrate both octopress-multilingual and octopress-paginate using latest Jekyll. And this is not working properly.

In this case is not possible to paginate a translated jekyll page using octopress-paginate.

What I'm trying to achieve is to have a .rb file in the _plugin folder to allow paginate i.e. posts based on a global variable defined in the _config.yml file. This is using the ruby method alias_method to override the current behavior.

_config.yml (extract)

lang: en

_plugins/.yml (extract)

module Octopress
  module Paginate
    def paginate(page)
      defaults = DEFAULT.merge(page.site.config['pagination'] || {})
      if page.data['paginate'].is_a? Hash
        page.data['paginate'] = defaults.merge(page.data['paginate'])
      else
        page.data['paginate'] = defaults
      end
      if tag = Jekyll.configuration({})['lang']
        page.data['paginate']['tags'] = Array(tag)
      end
      if category = page.data['paginate']['category']
        page.data['paginate']['categories'] = Array(category)
      end
      old_paginate(page)
    end
    alias_method :old_paginate, :paginate
  end
end

This is my layout:
_pages/news.html (extract)

---
layout: default
title: news
permalink: /latest/news/
paginate:
  collection:   posts
  per_page:     4                       # maximum number of items per page
  limit:        false
  permalink:    :num/  # pagination path (relative to template page)
---
<!-- Page code goes here-->
{% assign news = paginator.posts | where:'category', 'articles' | where:'lang', site.lang %}
{% for post in news %}
<!-- News code goes here-->
{% endfor %}
<!-- Page code goes here-->
{% for page in (1..paginator.total_pages) %}
<!-- Paginator code goes here-->
{% endfor %}
<!-- Page code goes here-->

In the above example, I'm filtering the posts by the language, but the paginator is not filtering by language.

The goal here would be to be able to paginate posts based on the lang tag in the _config.yml file.

Is this possible?

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

No branches or pull requests

1 participant