Update label syntax

Adds support for custom icons and better (more consistent) links
This commit is contained in:
Jonah Aragon 2020-05-13 09:52:11 -05:00
parent 462129717b
commit 8e1cfcf3bd
No known key found for this signature in database
GPG Key ID: 6A957C9A9A9429F7

View File

@ -42,21 +42,42 @@
{% if include.labels %} {% if include.labels %}
{% assign labels = include.labels | split:"|" %} {% assign labels = include.labels | split:"|" %}
{% for label in labels %} {% for label in labels %}
{% assign label_data = label | split:":" %} {% assign label_data = label | split:"::" %}
{% assign color = label_data[0] %} {% assign label_attr = include.label_data | split:"==" %}
{% assign text = label_data[1] %} {% for attr in label_attr %}
{% assign tooltip = label_data[2] | default: false %} {% assign i = forloop.index %}
{% assign help_icon = '<i class="far fa-question-circle"></i>' %} {% if label_attr[i] = "color" }
{% assign color = label_attr[i+1] %}
{% elsif label_attr[i] = "link" %}
{% assign link = label_attr[i+1] %}
{% elsif label_attr[i] = "text" %}
{% assign text = label_attr[i+1] %}
{% elsif label_attr[i] = "icon" %}
{% assign icon = label_attr[i+1] %}
{% elsif label_attr[i] = "tooltip" %}
{% assign tooltip = label_attr[i+1] %}
{% endif %}
{% endfor %}
{% if link %}
<a
href="{{ link }}" class="badge badge-{{ color }}"
{% if tooltip %}
data-toggle="tooltip"
title="{{ tooltip }}"><i class="{{ icon | default: "far fa-question-circle"}}"></i> {{ text }}
{% else %}><i class="{{ icon | default: "fas fa-external-link-alt"}}"></i> {{ text }}{% endif %}
</a>
{% else %}
<span <span
class="badge badge-{{color}}" class="badge badge-{{ color }}"
{% if tooltip %} {% if tooltip %}
data-toggle="tooltip" data-toggle="tooltip"
title="{{ tooltip }}" title="{{ tooltip }}"
> {{text}} {{ help_icon }} > <i class="{{ icon | default: "far fa-question-circle"}}"> {{text}}
{% else %} {% else %}
> {{text}} > {% if icon %}<i class="{{ icon }}"></i>{% endif %} {{text}}
{% endif %} {% endif %}
</span> </span>
{% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</p> </p>