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