Skip to content

Commit

Permalink
Merge pull request #58 from Voog/56_add_new_content_types
Browse files Browse the repository at this point in the history
Remove content type sorting constraint (#58)
  • Loading branch information
tanelj authored Dec 21, 2021
2 parents 86bd28b + ee2cfc2 commit 2f16c38
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions lib/voog/dtk/filemanager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ def read_manifest
end

def write_manifest(manifest)
if manifest["layouts"].is_a?(Array)
manifest["layouts"].sort! { |a, b| a["file"] <=> b["file"]}
%w(assets layouts).each do |k|
if manifest[k].is_a?(Array)
manifest[k].sort! { |a, b| a['file'] <=> b['file'] || 0 }
end
end
File.open('manifest.json', 'w+', encoding: 'UTF-8') do |file|
file << JSON.pretty_generate(manifest)
Expand Down Expand Up @@ -337,7 +339,7 @@ def generate_local_manifest(verbose = false, silent=false)
'preview_medium' => "",
'preview_small' => "",
'author' => "",
'layouts' => sort_layouts_by_content_type(layouts + components),
'layouts' => (layouts + components),
'assets' => assets
}
if @old_manifest
Expand All @@ -356,15 +358,6 @@ def generate_remote_manifest
generate_manifest get_layouts, get_layout_assets
end

def sort_layouts_by_content_type(layouts)
# make sure that 'blog' is before 'blog_article' and 'elements' is before 'element'
preferred_order = %w(page blog blog_article elements element error_401 error_404 photoset component)

layouts.sort do |a, b|
preferred_order.index(a.fetch('content_type')) <=> preferred_order.index(b.fetch('content_type'))
end
end

def generate_manifest(layouts = nil, layout_assets = nil)
layouts ||= get_layouts
layout_assets ||= get_layout_assets
Expand Down Expand Up @@ -403,8 +396,6 @@ def generate_manifest(layouts = nil, layout_assets = nil)
}
end

manifest[:layouts] = sort_layouts_by_content_type(manifest[:layouts])

manifest[:assets] = layout_assets.inject(Array.new) do |memo, a|

# kind is same as asset_type for kinds that are represented in the asset_folders hash, defaults to 'asset'
Expand Down

0 comments on commit 2f16c38

Please sign in to comment.