Octopress-multilingual with octopress-paginate 与最新的 jekyll 不兼容

Octopress-multilingual with octopress-paginate are not compatible with latest jekyll

我正在尝试使用最新的 Jekyll 集成 octopress-multilingual 和 octopress-paginate。这无法正常工作。

在这种情况下,无法使用 octopress-paginate 对已翻译的 jekyll 页面进行分页。

我想要实现的是在 _plugin 文件夹中有一个 .rb 文件以允许分页,即基于 _config.yml 文件中定义的全局变量的帖子。这是使用 ruby 方法 alias_method 覆盖当前行为。

_config.yml(摘录)

lang: en

_plugins/.yml(提取)

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

这是我的布局: _pages/news.html(摘录)

---
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-->

在上面的示例中,我按语言过滤帖子,但分页器并未按语言过滤。

这里的目标是能够根据 _config.yml 文件中的 lang 标签对帖子进行分页。

这可能吗?

最后,使用这个插件很容易实现 https://github.com/sverrirs/jekyll-paginate-v2

而不是 octopress 那个。只是使用名为 'lang' 的标签而不是名为 'locale'.

的标签