Skip to content

Commit

Permalink
Fixed sitemap generation for multiple frontend locales (#3218)
Browse files Browse the repository at this point in the history
* Fixed sitemap generation for multiple frontend locales

* Added else case to return correct url when there are 1 frontend locale
  • Loading branch information
Dmitriy Molodtsov authored and bricesanchez committed Jul 16, 2016
1 parent e2b752d commit c0f355b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/app/views/refinery/sitemap/index.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@ xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
# exclude sites that are external to our own domain.
page_url = if page.url.is_a?(Hash)
# This is how most pages work without being overriden by link_url
page.url.merge({:only_path => false})
page.url.merge({:only_path => false, locale: locale})
elsif page.url.to_s !~ /^http/
# handle relative link_url addresses.
[request.protocol, request.host_with_port, page.url].join
raw_url = [request.protocol, request.host_with_port, page.url].join
if (@locales.size > 1) && defined?(RoutingFilter::RefineryLocales)
filter = RoutingFilter::RefineryLocales.new
filter.around_generate({}) do
raw_url
end
else
raw_url
end
end

# Add XML entry only if there is a valid page_url found above.
Expand Down

0 comments on commit c0f355b

Please sign in to comment.