I want to make a navigation sorted by weight on my Jekyll site. I'm using this plugin, but I want to show in navigation only pages with weight, instead of showing pages without weight at the end of the list.
So I changed the plugin like this:
module Jekyll
class WeightedPagesGenerator < Generator
safe true
def generate(site)
site.pages.each do |page|
if page.data["weight"] != nil
site.config['weighted_pages'] = site.pages.sort_by { |a|
a.data['weight'] }
end
end
end
end
end
But I get an error: Generating... /_plugins/sorted_navigation.rb:10:in `sort_by': comparison of NilClass with 2 failed (ArgumentError).
Any idea how to make this work?