Use brand logos if ha_brand in search results (#26427)

This commit is contained in:
Joakim Sørensen 2023-03-02 13:41:01 +01:00 committed by GitHub
parent 8a9e58ed56
commit 4da4c3a8f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,7 +103,7 @@ var allComponents = [
{% capture category %}"{{ ha_category | slugify | downcase }}"{% endcapture %}
{% assign categories = categories | push: category %}
{%- endfor -%}
{url:"{{ component.url }}", title:"{{component.title}}", cat: [{{categories|join: ","}}], featured: {% if component.featured %}true{% else %}false{% endif %}, v: "{{major_version}}.{{minor_version}}", logo: "{{component.logo}}", domain: "{{component.ha_domain}}"},
{url:"{{ component.url }}", title:"{{component.title}}", cat: [{{categories|join: ","}}], featured: {% if component.featured %}true{% else %}false{% endif %}, v: "{{major_version}}.{{minor_version}}", logo: "{{component.logo}}", domain: "{{component.ha_domain}}", ha_brand: "{{component.ha_brand}}"},
{% endif -%}
{%- endfor -%}
false
@ -161,7 +161,7 @@ allComponents.pop(); // remove placeholder element at the end
components: [],
image: function () {
if (this.logo === '') {
return '<img src="https://brands.home-assistant.io/_/' + this.domain + '/logo.png" srcset="https://brands.home-assistant.io/_/' + this.domain + '/logo@2x.png 2x" loading="lazy">';
return `<img src="https://brands.home-assistant.io/${this.ha_brand ? "brands": "_"}/${this.domain}/logo.png" srcset="https://brands.home-assistant.io/${this.ha_brand ? "brands ": "_"}/${this.domain}/logo@2x.png 2x" loading="lazy">`;
} else {
return '<img data-src="/images/supported_brands/' + this.logo + '" loading="lazy">';
}