Add a dropdown for selecting a specific version

This commit is contained in:
Robbie Trencheny 2019-03-09 14:33:15 -08:00
parent bdbece9f3f
commit c22b20094d
No known key found for this signature in database
GPG Key ID: 1E236BB235BF0021
2 changed files with 17 additions and 1 deletions

View File

@ -70,6 +70,17 @@ module Jekyll
def canonical_url(input)
full_url(input).sub(/index\.\w+$/i, '')
end
# Sort an array of semvers
def semver_sort(input)
input.sort_by { |v|
val = v['name']
if val == "pre 0.7"
val = "0.6"
end
Gem::Version.new(val)
}
end
end
end

View File

@ -26,6 +26,7 @@ regenerate: false
{%- endfor -%}
{%- assign components = site.components | sort: 'title' -%}
{%- assign components_by_version = site.components | group_by: 'ha_release' | semver_sort | reverse -%}
{%- assign categories = components | map: 'ha_category' | join: ',' | join: ',' | split: ',' | uniq | sort -%}
{%- capture current_version -%}{{ site.current_major_version }}.{{ site.current_minor_version }}{% endcapture -%}
{%- assign added_one_ago_minor_version = site.current_minor_version|minus: 1 -%}
@ -48,7 +49,11 @@ Support for these components is provided by the Home Assistant community.
<a href='#version/{{ current_version }}' class="btn added_in_current_version">Added in {{ current_version }} ({{ current_version_components_count }})</a>
<a href='#version/{{ added_one_ago_version }}' class="btn added_one_version_ago">Added in {{ added_one_ago_version }} ({{ one_ago_version_components_count }})</a>
<a href='#version/{{ added_two_ago_version }}' class="btn added_two_versions_ago">Added in {{ added_two_ago_version }} ({{ two_ago_version_components_count }})</a>
Added in <select name="versions">
{%- for version in components_by_version -%}
<option value="#version/{{ version.name }}">{{ version.name }} ({{ version.items | size }})
{%- endfor -%}
</select>
{%- for category in categories -%}
{%- assign components_count = components | where: 'ha_category', category | size -%}
{%- if category and category != 'Other' and components_count != 0 -%}