From 627b6c1462ca05d10ab778074e35fe9942fb548a Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sun, 4 Mar 2012 23:17:30 -0800 Subject: [PATCH] A url helper that strips directory indexes --- middleman-core/lib/middleman-core/sitemap/page.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/middleman-core/lib/middleman-core/sitemap/page.rb b/middleman-core/lib/middleman-core/sitemap/page.rb index 8b25b084..47548cb1 100644 --- a/middleman-core/lib/middleman-core/sitemap/page.rb +++ b/middleman-core/lib/middleman-core/sitemap/page.rb @@ -182,6 +182,13 @@ module Middleman::Sitemap # TODO: Seems like .html shouldn't be hardcoded here end + # A path without the directory index - so foo/index.html becomes + # just foo. Best for linking. + # @return [String] + def url + '/' + destination_path.sub(/#{Regexp.escape(app.index_file)}$/, '') + end + # Get the relative path from the source # @return [String] def relative_path