preserve positions of the index and 404 page

This commit is contained in:
did 2011-02-12 15:32:35 +01:00
parent 94be90986d
commit 44a7c33f9f

View File

@ -57,6 +57,10 @@ module Locomotive
:published => true :published => true
}.merge(self.pages[fullpath] || {}).symbolize_keys }.merge(self.pages[fullpath] || {}).symbolize_keys
if %w(index 404).include?(fullpath)
attributes[:position] = fullpath == 'index' ? 0 : 1
end
# templatized ? # templatized ?
if content_type_slug = attributes.delete(:content_type) if content_type_slug = attributes.delete(:content_type)
attributes.merge!({ attributes.merge!({
@ -142,9 +146,9 @@ module Locomotive
position = nil position = nil
fullpath = data.keys.first.to_s fullpath = data.keys.first.to_s
if %w(index 404).include?(fullpath) unless %w(index 404).include?(fullpath)
position = fullpath == 'index' ? 0 : 1 # position = fullpath == 'index' ? 0 : 1
else # else
(segments = fullpath.split('/')).pop (segments = fullpath.split('/')).pop
position_key = segments.empty? ? 'index' : segments.join('/') position_key = segments.empty? ? 'index' : segments.join('/')