Skip to content

Commit 3c816d7

Browse files
authored
Merge pull request #31 from QuLogic/dedupe
Simplify setting icon links in the navbar
2 parents 37dd6fd + 1e2f469 commit 3c816d7

File tree

1 file changed

+9
-52
lines changed

1 file changed

+9
-52
lines changed

mpl_sphinx_theme/mpl_icon_links.html

Lines changed: 9 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,9 @@
1-
{%- block icon_links -%}
2-
{%- macro icon_link_nav_item(url, icon, name) -%}
3-
{%- if url | length > 2 %}
4-
<li class="nav-item">
5-
<a class="nav-link" href="{{ url }}" rel="noopener" target="_blank" title="{{ _(name) }}">
6-
<span><i class="{{ icon }}"></i></span>
7-
<label class="sr-only">{{ _(name) }}</label>
8-
</a>
9-
</li>
10-
{%- endif -%}
11-
{%- endmacro -%}
12-
{%- if theme_icon_links %}
13-
<ul id="navbar-icon-links" class="navbar-nav" aria-label="{{ _(theme_icon_links_label) }}">
14-
{%- block icon_link_shortcuts -%}
15-
{{ icon_link_nav_item(theme_github_url, "fab fa-github", "GitHub") -}}
16-
{{ icon_link_nav_item(theme_gitlab_url, "fab fa-gitlab", "GitLab") -}}
17-
{{ icon_link_nav_item(theme_bitbucket_url, "fab fa-bitbucket", "Bitbucket") -}}
18-
{{ icon_link_nav_item(theme_twitter_url, "fab fa-twitter", "Twitter") -}}
19-
{% endblock -%}
20-
{%- for icon_link in theme_icon_links -%}
21-
{{ icon_link_nav_item(icon_link["url"], icon_link["icon"], icon_link["name"]) -}}
22-
{%- endfor %}
23-
</ul>
24-
{%- else %}
25-
<ul id="navbar-icon-links" class="navbar-nav" aria-label="{{ _(theme_icon_links_label) }}">
26-
<li class="nav-item">
27-
<a class="nav-link" href="https://gitter.im/matplotlib" rel="noopener" target="_blank" title="gitter">
28-
<span><i class="fab fa-gitter"></i></span>
29-
<label class="sr-only">Gitter</label>
30-
</a>
31-
</li>
32-
<li class="nav-item">
33-
<a class="nav-link" href="https://discourse.matplotlib.org" rel="noopener" target="_blank" title="discourse">
34-
<span><i class="fab fa-discourse"></i></span>
35-
<label class="sr-only">Discourse</label>
36-
</a>
37-
</li>
38-
<li class="nav-item">
39-
<a class="nav-link" href="https://github.com/matplotlib/matplotlib" rel="noopener" target="_blank" title="GitHub">
40-
<span><i class="fab fa-github"></i></span>
41-
<label class="sr-only">GitHub</label>
42-
</a>
43-
</li>
44-
<li class="nav-item">
45-
<a class="nav-link" href="https://twitter.com/matplotlib/" rel="noopener" target="_blank" title="twitter">
46-
<span><i class="fab fa-twitter"></i></span>
47-
<label class="sr-only">Twitter</label>
48-
</a>
49-
</li>
50-
</ul>
51-
{%- endif %}
52-
{%- endblock %}
1+
{%- if not theme_icon_links -%}
2+
{%- set theme_icon_links = [
3+
{ "url": "https://gitter.im/matplotlib", "icon": "fab fa-gitter", "name": "Gitter" },
4+
{ "url": "https://discourse.matplotlib.org", "icon": "fab fa-discourse", "name": "Discourse" },
5+
{ "url": "https://github.com/matplotlib/matplotlib", "icon": "fab fa-github", "name": "GitHub" },
6+
{ "url": "https://twitter.com/matplotlib/", "icon": "fab fa-twitter", "name": "Twitter" },
7+
] -%}
8+
{%- endif -%}
9+
{% extends "navbar-icon-links.html" %}

0 commit comments

Comments
 (0)