Add hash_property
This commit is contained in:
parent
4f20d7ab24
commit
ae7e485474
|
@ -213,12 +213,12 @@ module Jekyll
|
|||
end
|
||||
|
||||
input.sort { |a, b|
|
||||
if !a[key].nil? && b[key].nil?
|
||||
if !hash_property(a, key).nil? && hash_property(b, key).nil?
|
||||
- order
|
||||
elsif a[key].nil? && !b[key].nil?
|
||||
elsif hash_property(a, key).nil? && !hash_property(b, key).nil?
|
||||
+ order
|
||||
else
|
||||
a[key] <=> b[key]
|
||||
hash_property(a, key) <=> hash_property(b, key)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
@ -250,5 +250,15 @@ module Jekyll
|
|||
item[property.to_s]
|
||||
end
|
||||
end
|
||||
|
||||
def hash_property(hash, property)
|
||||
if hash.respond_to?('[]'.freeze)
|
||||
hash[property]
|
||||
elsif hash.respond_to?(property)
|
||||
hash.send(property)
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue