Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed localization of paginated resources error #790

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading