Module: Jekyll::Filters::Order

Defined in:
lib/jekyll/filters/order.rb

Instance Method Summary collapse

Instance Method Details

#order(input) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/jekyll/filters/order.rb', line 6

def order(input)
  return input unless input.respond_to? :sort_by

  input.sort_by do |post|
    case post
    when Jekyll::Drops::DocumentDrop, Hash
      [post['order'].to_i, post['date']]
    when Jekyll::Document, Jekyll::Page
      [post.data['order'].to_i, post.data['date']]
    else
      Jekyll.logger.warn 'Order:', "Not a post: #{post.inspect}"
      [0, nil]
    end
  end.reverse
end