diff --git a/lib/locomotive/steam/adapters/filesystem/yaml_loaders/section.rb b/lib/locomotive/steam/adapters/filesystem/yaml_loaders/section.rb index 9cee9b6a..af00e677 100644 --- a/lib/locomotive/steam/adapters/filesystem/yaml_loaders/section.rb +++ b/lib/locomotive/steam/adapters/filesystem/yaml_loaders/section.rb @@ -15,9 +15,16 @@ def load(scope) private def load_list - Dir.glob(File.join(path, "*.{#{template_extensions.join(',')}}")).map do |filepath| - slug = File.basename(filepath).split('.').first - build(filepath, slug.permalink) + Dir.glob(File.join(path, "**", "*.{#{template_extensions.join(',')}}")).map do |filepath| + basename = File.basename(filepath) + subfolder = filepath.sub(path, '').sub(/^\//, '').sub(basename, '') + slug = basename.split('.').first.permalink + + if subfolder != '' + slug.prepend(subfolder) + end + + build(filepath, slug) end end diff --git a/lib/locomotive/steam/adapters/filesystem/yaml_loaders/snippet.rb b/lib/locomotive/steam/adapters/filesystem/yaml_loaders/snippet.rb index 16971357..6ebfc3d4 100644 --- a/lib/locomotive/steam/adapters/filesystem/yaml_loaders/snippet.rb +++ b/lib/locomotive/steam/adapters/filesystem/yaml_loaders/snippet.rb @@ -44,11 +44,23 @@ def update(element, filepath, locale) end def each_file(&block) - Dir.glob(File.join(path, "*.{#{template_extensions.join(',')}}")).each do |filepath| - slug, locale = File.basename(filepath).split('.')[0..1] - locale = default_locale if template_extensions.include?(locale) + Dir.glob(File.join(path, "**", "*.{#{template_extensions.join(',')}}")).each do |filepath| + basename = File.basename(filepath) + subfolder = filepath.sub(path, '').sub(/^\//, '').sub(basename, '') - yield(filepath, slug.permalink, locale.to_sym) + slug, locale = basename.split('.')[0..1] + + if template_extensions.include?(locale) + locale = default_locale + end + + slug = slug.permalink + + if subfolder != '' + slug.prepend(subfolder) + end + + yield(filepath, slug, locale.to_sym) end end