Added strip_index_file option for configuring urls
This commit is contained in:
parent
2117cbac79
commit
3cbda0ee36
|
@ -93,7 +93,11 @@ module Middleman
|
|||
# @return [String]
|
||||
set :index_file, "index.html"
|
||||
|
||||
# Whether to include a trailing slash on links to directory indexes
|
||||
# Whether to strip the index file name off links to directory indexes
|
||||
# @return [Boolean]
|
||||
set :strip_index_file, true
|
||||
|
||||
# Whether to include a trailing slash when stripping the index file
|
||||
# @return [Boolean]
|
||||
set :trailing_slash, true
|
||||
|
||||
|
|
|
@ -141,8 +141,12 @@ module Middleman
|
|||
# just foo. Best for linking.
|
||||
# @return [String]
|
||||
def url
|
||||
File.join(app.respond_to?(:http_prefix) ? app.http_prefix : '/',
|
||||
destination_path.sub(/\/#{Regexp.escape(app.index_file)}$/, app.trailing_slash ? '/' : ''))
|
||||
url_path = destination_path
|
||||
if app.strip_index_file
|
||||
url_path = url_path.sub(/\/#{Regexp.escape(app.index_file)}$/,
|
||||
app.trailing_slash ? '/' : '')
|
||||
end
|
||||
File.join(app.respond_to?(:http_prefix) ? app.http_prefix : '/', url_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue