Make the asset_url helper use the sitemap page's destination_path if it's available, which means extensions that rewrite asset paths using reroute get rewritten paths output from all path helpers for free. This was necessary to make asset_hash work with asset_host.
This commit is contained in:
parent
c27a288f1a
commit
7e816c04c0
|
@ -24,7 +24,14 @@ module Middleman::CoreExtensions::Assets
|
||||||
# @return [String] The fully qualified asset url
|
# @return [String] The fully qualified asset url
|
||||||
def asset_url(path, prefix="")
|
def asset_url(path, prefix="")
|
||||||
# Don't touch assets which already have a full path
|
# Don't touch assets which already have a full path
|
||||||
path.include?("://") ? path : File.join(http_prefix, prefix, path)
|
if path.include?("//")
|
||||||
|
path
|
||||||
|
else # rewrite paths to use their destination path
|
||||||
|
path = File.join(prefix, path)
|
||||||
|
path = sitemap.page(path).destination_path if sitemap.exists?(path)
|
||||||
|
|
||||||
|
File.join(http_prefix, path)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in a new issue