Skip to content

Commit

Permalink
Fixed localization of paginated resources error (#790)
Browse files Browse the repository at this point in the history
* Fixed localization of paginated resources error

* Refactor for RuboCop

* Make localeless_path more restrictive so it won't make incorrect replacements.
  • Loading branch information
jclusso authored Oct 10, 2023
1 parent f3f2d96 commit 50d4233
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion bridgetown-core/lib/bridgetown-core/concerns/localizable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,24 @@ def all_locales
end

matching_resources = result_set.select do |item|
item.relative_path.parent == relative_path.parent && item.data.slug == data.slug
matches_resource?(item)
end

matching_resources.sort_by do |item|
site.config.available_locales.index item.data.locale
end
end

def matches_resource?(item)
if item.relative_path.is_a?(String)
item.localeless_path == localeless_path
else
item.relative_path.parent == relative_path.parent
end && item.data.slug == data.slug
end

def localeless_path
relative_path.gsub(/\A#{data.locale}\//, "")
end
end
end

0 comments on commit 50d4233

Please sign in to comment.