Skip to content

Commit

Permalink
Improve version selector (#1440)
Browse files Browse the repository at this point in the history
* Don't show install man page links from other commands

* Only show version selector if there's more than one version

* Rename block variable to clarify it's actually used
deivid-rodriguez authored Jan 24, 2025
1 parent f1d0b88 commit 4f6e073
Showing 2 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions helpers/config_helper.rb
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ def versions
config[:versions]
end

def versions_grouped_by_status
versions.reverse.group_by { status(_1) }
def versions_with_documentation_page
versions.select {|version| documentation_path(current_page_without_version, version) }
end

private
19 changes: 10 additions & 9 deletions source/partials/_commands_sidebar.haml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
- primary_commands = %w(bundle-install.1 bundle-update.1 bundle-cache.1 bundle-exec.1 bundle-config.1 bundle-help.1)

%h4 Choose version
%select.version-selects.form-select.mb-3
- versions_grouped_by_status.each do |status, _versions|
%optgroup{label: status}
- _versions.each do |version|
- selected = version == current_visible_version
- value = documentation_path(current_page_without_version, version) || documentation_path('bundle-install.1', version)
%option{selected: selected, value: value}
= version
- if versions_with_documentation_page.size > 1
%h4 Choose version
%select.version-selects.form-select.mb-3
- versions_with_documentation_page.reverse.group_by { status(_1) }.each do |status, versions|
%optgroup{label: status}
- versions.each do |version|
- selected = version == current_visible_version
- value = documentation_path(current_page_without_version, version)
%option{selected: selected, value: value}
= version
%h4 General
%ul
%li{class: current_page.url.end_with?("whats_new.html") ? "active" : ""}

0 comments on commit 4f6e073

Please sign in to comment.