source/_templates/icon-links.html (40 lines of code) (raw):

{# Origin: https://github.com/pydata/pydata-sphinx-theme/blob/d4f888ec5e63628d6e3c5bf81b6b689a20b3927c/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html #} {# Displays icon-links as list items. #} {%- macro icon_link_nav_item(url, icon, name, type, attributes='') -%} {% set include = pagename in attributes['included_to'] if 'included_to' in attributes.keys() else True %} {% set exclude = pagename in attributes['excluded_from'] if 'excluded_from' in attributes.keys() else False %} {% set show = include and not exclude %} {%- if (url | length > 2) and show %} <li class="nav-item"> {%- set attributesDefault = { "href": url, "title": name, "class": "nav-link", "rel": "noopener", "target": "_blank", "data-bs-toggle": "tooltip", "data-bs-placement": "bottom"} %} {%- 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 }} fa-lg" aria-hidden="true"></i></span> <span class="sr-only">{{ name }}</span> {%- 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 -%} {%- if theme_icon_links -%} <ul class="navbar-icon-links navbar-nav" aria-label="{{ theme_icon_links_label }}"> {%- 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> {%- endif -%}