lib/alula/generators/paginate.rb in alula-0.4.13 vs lib/alula/generators/paginate.rb in alula-0.4.14

- old
+ new

@@ -1,16 +1,17 @@ module Alula class Paginate < Generator def generate # Loop all languages and count posts per language - @languages = {} - self.site.content.posts.each do |post| - post.languages.each do |lang| - @languages[lang] ||= [] - @languages[lang] << post - end - end + @languages = fetch_languages + # @languages = {} + # self.site.content.posts.each do |post| + # post.languages.each do |lang| + # @languages[lang] ||= [] + # @languages[lang] << post + # end + # end # Maximum amount of posts num_posts = self.site.content.posts.count # Maximum number of required pages pages = (num_posts / self.options.items).ceil @@ -37,25 +38,25 @@ sidebar: false, template: self.options.template, site: self.site, view: self.options.view || "paginate", }, - :previous => ->(hook, locale = nil) { - pos = self.navigation(locale).index(self) - if pos and pos < (self.navigation(locale).count - 1) - self.navigation(locale)[pos + 1] - else - nil - end - }, - :next => ->(hook, locale = nil) { - pos = self.navigation(locale).index(self) - if pos and pos > 0 - self.navigation(locale)[pos - 1] - else - nil - end - }, + # :previous => ->(hook, locale = nil) { + # pos = self.navigation(locale).index(self) + # if pos and pos < (self.navigation(locale).count - 1) + # self.navigation(locale)[pos + 1] + # else + # nil + # end + # }, + # :next => ->(hook, locale = nil) { + # pos = self.navigation(locale).index(self) + # if pos and pos > 0 + # self.navigation(locale)[pos - 1] + # else + # nil + # end + # }, :navigation => ->(hook, locale = nil) { locale ||= self.current_locale || self.site.config.locale @navigation[locale] ||= self.site.content.pages.select { |item| item.metadata.generator == self.generator and item.languages.include?(locale) } } )