1
Fork 0
holllo-org/source/includes/macros.html

44 lines
1.5 KiB
HTML

{%- macro iconLink(link, text='Unknown', icon='none') -%}
{%- set link = linkFromType(link, icon) -%}
<a class="icon-link" href="{{ link }}" rel="noopener noreferrer">
<img alt="{{ text }}" src="/assets/{{ icon }}.png">
</a>
{%- endmacro -%}
{%- macro link(link, text='', type='default', linkAsText=false) -%}
{%- if linkAsText -%}
{%- set text = link -%}
{%- endif -%}
{%- set link = linkFromType(link, type) -%}
<a href="{{ link }}" rel="noopener noreferrer">{{ text }}</a>
{%- endmacro -%}
{%- macro linkFromType(link, type='default') -%}
{%- if type === 'github' -%}
{%- set text = 'GitHub' -%}
{%- set link = 'https://github.com/' + link -%}
{%- elif type === 'mozilla-firefox' -%}
{%- set text = 'Mozilla Firefox' -%}
{%- set link = 'https://addons.mozilla.org/firefox/addon/' + link -%}
{%- elif type === 'google-chrome' -%}
{%- set text = 'Google Chrome' -%}
{%- set link = 'https://chrome.google.com/webstore/detail/' + link -%}
{%- elif type === 'microsoft-edge' -%}
{%- set text = 'Microsoft Edge' -%}
{%- set link = 'https://microsoftedge.microsoft.com/addons/detail/' + link -%}
{%- elif type === 'crates-io' -%}
{%- set text = 'Crates.io' -%}
{%- set link = 'https://crates.io/crates/' + link -%}
{%- elif type === 'pypi' -%}
{%- set text = 'Python Package Index' -%}
{%- set link = 'https://pypi.org/project/' + link -%}
{%- elif type === 'npm' -%}
{%- set text = 'npm' -%}
{%- set link = 'https://www.npmjs.com/package/' + link -%}
{%- endif -%}
{{- link -}}
{%- endmacro -%}