diff --git a/CHANGELOG.md b/CHANGELOG.md index ced25050..2443d764 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ master === +* Fix ignoring layouts from the sitemap when the source directory has been set to something other than 'source'. #896 * Move more into core, autoloaded if gems are available. * DataStore may now be accessed like a hash with #[] and #has_key?. #880 * The i18n extension now supports providing localized templates as separate files, like index.es.html.haml. #816, #823 diff --git a/middleman-core/features/custom-source.feature b/middleman-core/features/custom-source.feature new file mode 100644 index 00000000..7746e38c --- /dev/null +++ b/middleman-core/features/custom-source.feature @@ -0,0 +1,7 @@ +Feature: Support customizing the source directory name + + Scenario: Layouts don't try to build + Given a successfully built app at "custom-src-app" + When I cd to "build" + Then the following files should not exist: + | layouts/layout.html | diff --git a/middleman-core/fixtures/custom-src-app/config.rb b/middleman-core/fixtures/custom-src-app/config.rb new file mode 100644 index 00000000..e23d2bd3 --- /dev/null +++ b/middleman-core/fixtures/custom-src-app/config.rb @@ -0,0 +1 @@ +set :source, 'src' diff --git a/middleman-core/fixtures/custom-src-app/src/index.html b/middleman-core/fixtures/custom-src-app/src/index.html new file mode 100644 index 00000000..e69de29b diff --git a/middleman-core/fixtures/custom-src-app/src/layouts/layout.html.erb b/middleman-core/fixtures/custom-src-app/src/layouts/layout.html.erb new file mode 100644 index 00000000..37f0bddb --- /dev/null +++ b/middleman-core/fixtures/custom-src-app/src/layouts/layout.html.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/middleman-core/lib/middleman-core/sitemap.rb b/middleman-core/lib/middleman-core/sitemap.rb index 02554cca..958d6427 100644 --- a/middleman-core/lib/middleman-core/sitemap.rb +++ b/middleman-core/lib/middleman-core/sitemap.rb @@ -35,8 +35,8 @@ module Middleman # Files starting with an underscore, but not a double-underscore :partials => proc { |file| file =~ %r{/_} && file !~ %r{/__} }, - :layout => proc { |file| - file.start_with?('source/layout.') || file.start_with?('source/layouts/') + :layout => proc { |file, app| + file.start_with?(File.join(app.config[:source], 'layout.')) || file.start_with?(File.join(app.config[:source], 'layouts/')) } }, 'Callbacks that can exclude paths from the sitemap' diff --git a/middleman-core/lib/middleman-core/sitemap/extensions/on_disk.rb b/middleman-core/lib/middleman-core/sitemap/extensions/on_disk.rb index d311973d..824daaf4 100644 --- a/middleman-core/lib/middleman-core/sitemap/extensions/on_disk.rb +++ b/middleman-core/lib/middleman-core/sitemap/extensions/on_disk.rb @@ -46,7 +46,11 @@ module Middleman return false unless path ignored = @app.config[:ignored_sitemap_matchers].any? do |name, callback| - callback.call(file) + if callback.arity == 1 + callback.call(file) + else + callback.call(file, @app) + end end @file_paths_on_disk << file unless ignored