class Middleman::Extensions::AssetHash
def rewrite_url(asset_path, dirpath, _request_path)
def rewrite_url(asset_path, dirpath, _request_path) uri = ::Middleman::Util.parse_uri(asset_path) relative_path = !uri.path.start_with?('/') full_asset_path = if relative_path dirpath.join(asset_path).to_s else asset_path end return unless asset_page = app.sitemap.find_resource_by_destination_path(full_asset_path) || app.sitemap.find_resource_by_path(full_asset_path) replacement_path = "/#{asset_page.destination_path}" replacement_path = Pathname.new(replacement_path).relative_path_from(dirpath).to_s if relative_path replacement_path end