<commit_before>module Jekyll
  class SortedNavigationBuilder < Generator
  
    safe true
    priority :high

    def generate(site)
      site.config['primary_navigation'] = site.pages.select{|p| !p.to_liquid["primarynavorder"].nil?}.sort_by! { |p| p.to_liquid["primarynavorder"] }
      
      sorted_nav = Hash.new { |hash, key| hash[key] = [] }
      site.pages.select{|p| !p.to_liquid["navorder"].nil?}.sort_by! { |p| p.to_liquid["navorder"] }.each do |p|
        sorted_nav[p.to_liquid["subfolder"]] << p
      end
      site.config["sorted_navigation"] = sorted_nav
    end

  end
end<commit_msg>added date sorting for pages, will sort by date descending<commit_after>module Jekyll
  class SortedNavigationBuilder < Generator
  
    safe true
    priority :high

    def generate(site)
      site.config['primary_navigation'] = site.pages.select{|p| !p.to_liquid["primarynavorder"].nil?}.sort_by! { |p| p.to_liquid["primarynavorder"] }
      
      sorted_nav = Hash.new { |hash, key| hash[key] = [] }
      # sort pages that have date specified, order by date descending
      site.pages.select{|p| !p.to_liquid["date"].nil? && p.to_liquid["navorder"].nil?}.sort! { |a, b| b.to_liquid["date"] <=> a.to_liquid["date"] }.each do |p|
        sorted_nav[p.to_liquid["subfolder"]] << p
      end
      
      # sort pages that have navorder specified, takes precedence over date
      site.pages.select{|p| !p.to_liquid["navorder"].nil?}.sort_by! { |p| p.to_liquid["navorder"] }.each do |p|
        sorted_nav[p.to_liquid["subfolder"]] << p
      end
      site.config["sorted_navigation"] = sorted_nav
    end

  end
end
{'fraction_non_alphanumeric': 0.15147783251231528, 'fraction_numerical': 0.0, 'mean_word_length': 3.4277929155313354, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1034172', 'n_tokens_mistral': 587, 'n_tokens_neox': 548, 'n_words': 113}