Upgrade url_for to search for resources relative to their destination paths as well as their source paths. This would fix #818.
This commit is contained in:
parent
8f4057736a
commit
22dace72df
2 changed files with 15 additions and 7 deletions
|
@ -247,7 +247,16 @@ module Middleman
|
|||
current_source_dir = Pathname('/' + this_resource.path).dirname
|
||||
url_path = current_source_dir.join(url_path) if url_path.relative?
|
||||
resource = app.sitemap.find_resource_by_path(url_path.to_s)
|
||||
resource_url = resource.url if resource
|
||||
if resource
|
||||
resource_url = resource.url
|
||||
else
|
||||
# Try to find a resource relative to destination paths
|
||||
url_path = Pathname(uri.path)
|
||||
current_source_dir = Pathname('/' + this_resource.destination_path).dirname
|
||||
url_path = current_source_dir.join(url_path) if url_path.relative?
|
||||
resource = app.sitemap.find_resource_by_destination_path(url_path.to_s)
|
||||
resource_url = resource.url if resource
|
||||
end
|
||||
elsif options[:find_resource] && uri.path
|
||||
resource = app.sitemap.find_resource_by_path(uri.path)
|
||||
resource_url = resource.url if resource
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue