forked from pydata/pydata-sphinx-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
icon-links.html
39 lines (38 loc) · 2.17 KB
/
icon-links.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{%- macro icon_link_nav_item(url, icon, name, type, attributes='') -%}
{%- if url | length > 2 %}
<li class="nav-item">
{%- set attributesDefault = { "href": url, "title": name, "class": "nav-link", "rel": "noopener", "target": "_blank", "data-toggle": "tooltip"} %}
{%- if attributes %}{% for key, val in attributes.items() %}
{% set _ = attributesDefault.update(attributes) %}
{% endfor %}{% endif -%}
{% set attributeString = [] %}
{% for key, val in attributesDefault.items() %}
{%- set _ = attributeString.append('%s="%s"' % (key, val)) %}
{% endfor %}
{% set attributeString = attributeString | join(" ") -%}
<a {{ attributeString }}>
{%- if type == "fontawesome" -%}
<span><i class="{{ icon }}"></i></span>
<label class="sr-only">{{ _(name) }}</label>
{%- elif type == "local" -%}
<img src="{{ pathto(icon, 1) }}" class="icon-link-image" alt="{{ _(name) }}"/>
{%- elif type == "url" -%}
<img src="{{ icon }}" class="icon-link-image" alt="{{ _(name) }}"/>
{%- else %}
<span>Incorrectly configured icon link. Type must be `fontawesome`, `url` or `local`.</span>
{%- endif -%}
</a>
</li>
{%- endif -%}
{%- endmacro -%}
<ul id="navbar-icon-links" class="navbar-nav" aria-label="{{ _(theme_icon_links_label) }}">
{%- block icon_link_shortcuts -%}
{{ icon_link_nav_item(theme_github_url, "fa-brands fa-square-github", "GitHub", "fontawesome") -}}
{{ icon_link_nav_item(theme_gitlab_url, "fa-brands fa-square-gitlab", "GitLab", "fontawesome") -}}
{{ icon_link_nav_item(theme_bitbucket_url, "fa-brands fa-bitbucket", "Bitbucket", "fontawesome") -}}
{{ icon_link_nav_item(theme_twitter_url, "fa-brands fa-square-twitter", "Twitter", "fontawesome") -}}
{% endblock -%}
{%- for icon_link in theme_icon_links -%}
{{ icon_link_nav_item(icon_link["url"], icon_link["icon"], icon_link["name"], icon_link.get("type", "fontawesome"), icon_link.get("attributes", {})) -}}
{%- endfor %}
</ul>