Skip to content

Commit

Permalink
Remove unnecessary URL checks
Browse files Browse the repository at this point in the history
  • Loading branch information
adi-unni committed Oct 9, 2023
1 parent 02cc4ed commit 5eb4f71
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/components/card/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,18 @@
{% set titleSize = params.titleSize | default('2') %}

<div class="ons-card">

{%- if params.url -%}
<a href="{{ params.url }}" class="ons-card__link">
{%- endif -%}
<h{{ titleSize }} class="ons-card__title ons-card__title--reorder {{ params.titleClasses | default('ons-u-fs-m')}}" id="{{ params.id }}">
{{ params.title }}
</h{{ titleSize }}>
{%- if params.image -%}
{% if params.image.smallSrc %}
<img class="ons-card__image ons-u-mb-s ons-card__image--reorder" height="200" width="303"{% if params.image.largeSrc %} srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x"{% endif %} src="{{ params.image.smallSrc }}" alt="{{ params.image.alt }}" loading="lazy">
{% elif params.image == true or params.image.placeholderURL %}
<img class="ons-card__image ons-u-mb-s ons-card__image--reorder" height="100" width="303" srcset="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png 1x, {{ params.image.placeholderURL if params.image.placeholderURL }}/img/large/placeholder-card.png 2x" src="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png" alt="" loading="lazy">
{% endif %}
{%- endif -%}
{%- if params.url -%}
</a>
<a href="{{ params.url }}" class="ons-card__link">
<h{{ titleSize }} class="ons-card__title ons-card__title--reorder {{ params.titleClasses | default('ons-u-fs-m')}}" id="{{ params.id }}">
{{ params.title }}
</h{{ titleSize }}>
{%- if params.image -%}
{% if params.image.smallSrc %}
<img class="ons-card__image ons-u-mb-s ons-card__image--reorder" height="200" width="303"{% if params.image.largeSrc %} srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x"{% endif %} src="{{ params.image.smallSrc }}" alt="{{ params.image.alt }}" loading="lazy">
{% elif params.image == true or params.image.placeholderURL %}
<img class="ons-card__image ons-u-mb-s ons-card__image--reorder" height="100" width="303" srcset="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png 1x, {{ params.image.placeholderURL if params.image.placeholderURL }}/img/large/placeholder-card.png 2x" src="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png" alt="" loading="lazy">
{% endif %}
{%- endif -%}
</a>

<p id="{{ params.textId }}">{{ params.text }}</p>

Expand Down

0 comments on commit 5eb4f71

Please sign in to comment.