Rename Jekyll components collection to integrations

This commit is contained in:
Franck Nijhof 2019-09-29 22:03:21 +02:00
parent 57c6dec6c2
commit 611115e1ea
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
2 changed files with 217 additions and 184 deletions

View File

@ -63,7 +63,7 @@ titlecase: true # Converts page and post titles to titlecase
# page_asides:
collections:
components:
integrations:
output: true
cookbook:
output: true

View File

@ -10,7 +10,7 @@ regenerate: false
{%- comment -%}Can't use where to count nil because of https://github.com/jekyll/jekyll/issues/6038{%- endcomment -%}
{%- assign tot = 0 -%}
{%- for comp in site.components -%}
{%- for comp in site.integrations -%}
{%- if comp.ha_category -%}
{%- if comp.ha_category.first -%}
{%- assign tot = tot | plus: comp.ha_category.size -%}
@ -20,8 +20,8 @@ regenerate: false
{%- endif %}
{%- endfor -%}
{%- assign components = site.components | sort: 'title' -%}
{%- assign components_by_version = site.components | group_components_by_release -%}
{%- assign components = site.integrations | sort: 'title' -%}
{%- assign components_by_version = site.integrations | group_components_by_release -%}
{%- assign categories = components | map: 'ha_category' | join: ',' | join: ',' | split: ',' | uniq | sort -%}
<p class='note'>
@ -38,7 +38,8 @@ Support for these integrations is provided by the Home Assistant community.
{%- for group in components_by_version -%}
<optgroup label="{{ group.label }} ({{group.new_components_count}})">
{%- for version in group.versions -%}
<option value="#version/{{ version.label }}">{{ version.label }} ({{ version.new_components_count }})</option>
<option value="#version/{{ version.label }}">{{ version.label }} ({{ version.new_components_count }})
</option>
{%- endfor -%}
</optgroup>
{%- endfor -%}
@ -84,19 +85,50 @@ Support for these integrations is provided by the Home Assistant community.
<script type="text/javascript">
// This object contains all components we have
var allComponents = [
{%- for component in components -%}
{%- if component.ha_category -%}
{%- assign sliced_version = component.ha_release | split: '.' -%}
{%- assign minor_version = sliced_version[1]|plus: 0 -%}
{%- assign major_version = sliced_version[0]|plus: 0 -%}
{%- assign featured_first = true -%}
{%- for ha_category in component.ha_category -%}
{url:"{{ component.url }}", title:"{{component.title}}", cat:"{{ha_category | slugify}}", featured: {% if component.featured and featured_first %}true{% else %}false{% endif %}, v: "{{major_version}}.{{minor_version}}", logo: "{{component.logo}}"},
{%- assign featured_first = false -%}
{%- endfor -%}
{% endif -%}
{%- endfor -%}
var allComponents = [{
% -
for component in components - %
} {
% -
if component.ha_category - %
} {
% -assign sliced_version = component.ha_release | split: '.' - %
} {
% -assign minor_version = sliced_version[1] | plus: 0 - %
} {
% -assign major_version = sliced_version[0] | plus: 0 - %
} {
% -assign featured_first = true - %
} {
% -
for ha_category in component.ha_category - %
} {
url: "{{ component.url }}",
title: "{{component.title}}",
cat: "{{ha_category | slugify}}",
featured: {
%
if component.featured and featured_first %
}
true {
%
else %
}
false {
% endif %
},
v: "{{major_version}}.{{minor_version}}",
logo: "{{component.logo}}"
},
{
% -assign featured_first = false - %
} {
% -endfor - %
} {
% endif - %
} {
% -endfor - %
}
false
];
allComponents.pop(); // remove placeholder element at the end
@ -240,7 +272,8 @@ allComponents.pop(); // remove placeholder element at the end
function debounce(func, wait, immediate) {
var timeout;
return function () {
var context = this, args = arguments;
var context = this,
args = arguments;
var later = function () {
timeout = null;
if (!immediate) {