icon.html 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. {% removeemptylines %}
  2. {% assign icon-name = include.icon %}
  3. {% assign replace-to = "icon" %}
  4. {% if include.class %}
  5. {% assign replace-to = replace-to | append: ' ' | append: include.class %}
  6. {% endif %}
  7. {% if include.color %}
  8. {% assign replace-to = replace-to | append: ' text-' | append: include.color %}
  9. {% endif %}
  10. {% if include.filled %}
  11. {% assign replace-to = replace-to | append: ' icon-filled' %}
  12. {% endif %}
  13. {% if include.inline %}
  14. {% assign replace-to = replace-to | append: ' icon-inline' %}
  15. {% endif %}
  16. {% if include['size'] %}
  17. {% assign replace-to = replace-to | append: ' icon-' | append: include['size'] %}
  18. {% endif %}
  19. {% assign replace-to = 'class="' | append: replace-to | append: '"' %}
  20. {% if site.use-iconfont %}
  21. <i class="icon ti ti-{{ icon-name }}{% if include.color %} {{ include.color }}{% endif %}{% if include.filled %} icon-filled{% endif %}{% if include.class %} {{ include.class }}{% endif %}"></i>
  22. {% else %}
  23. <!-- Download SVG icon from http://tabler-icons.io/i/{{ icon-name }} -->
  24. {% assign svg-icon = site.data.icons[icon-name].svg | default: '' %}
  25. {{ svg-icon | replace_regex: 'class=\"[^"]+\"', replace-to }}
  26. {% endif %}
  27. {% endremoveemptylines %}