Skip to content

Commit 41a9804

Browse files
committed
Unified external+local links + multiple dropdowns
1 parent 28e4e74 commit 41a9804

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

README.rst

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ The options are:
4646

4747
* `'google_analytics'` : str, your Google analytics ID, if any.
4848
* `'nav_links'` : tuple list, a list of ('Link display name', 'local.file'), contains the links to the local documentation, in the top navigation bar.
49-
* `'external_nav_links'` : same as above but contains external links.
50-
* `'external_nav_links_dropdown'` : same as above but contains multiple links in a dropdown.
51-
In that case, `'external_nav_links_dropdown_title'` indicates the text of the dropdown button.
49+
if the link starts with 'http', it will be considered as an external link.
50+
* `'nav_dropdowns'` : same as above but contains multiple links in a dropdown.
5251

5352

5453
**Example:**
@@ -58,13 +57,13 @@ The options are:
5857
html_theme_options = {
5958
'google_analytics' : 'YOUR_GOOGLE_ANALYTICS_ID',
6059
'nav_links' : [('Install', 'installation'),
61-
('User Guide', 'user_guide/index')]
62-
'external_nav_links' : [('TensorLy', 'https://github.com/tensorly/tensorly'),
63-
('TensorLy-Torch', 'https://github.com/tensorly/torch')],
64-
'external_nav_links_dropdown_title': 'LinksInDropdown',
65-
'external_nav_links_dropdown' : [('TensorLy', 'http://tensorly.org/dev'),
66-
('TensorLy-Viz', 'http://tensorly.org/viz'),
67-
('TensorLy-Quantum', 'http://tensorly.org/quantum')],
60+
('User Guide', 'user_guide/index'),
61+
('TensorLy', 'https://github.com/tensorly/tensorly'),
62+
('TensorLy-Torch', 'https://github.com/tensorly/torch')],
63+
'nav_dropdowns': [('LinksInDropdown', [('TensorLy', 'http://tensorly.org/dev'),
64+
('TensorLy-Viz', 'http://tensorly.org/viz'),
65+
('TensorLy-Quantum', 'http://tensorly.org/quantum')]
66+
)],
6867
}
6968

7069

tensorly_sphinx_theme/navigation.html

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,33 @@
3333
{# RIGHT #}
3434

3535
{%- for (name, link) in theme_nav_links %}
36-
<a class="navbar-item" href="{{pathto(link)}}">
36+
{%- if link.startswith('http') %}
37+
<a class="navbar-item" href="{{link}}" target="_blank">
38+
{%- else %}
39+
<a class="navbar-item" href="{{pathto(link)}}">
40+
{%- endif %}
3741
{{name}}
3842
</a>
3943
{%- endfor %}
40-
{%- for (name, link) in theme_external_nav_links %}
41-
<a class="navbar-item" href="{{link}}" target="_blank">
42-
{{name}}
43-
</a>
44-
{%- endfor %}
45-
{%- if theme_external_nav_links_dropdown_title %}
44+
{%- if theme_nav_dropdowns %}
45+
{%- for (dropdown_title, dropdown_links) in theme_nav_dropdowns %}
4646
<div class="navbar-item has-dropdown is-hoverable is-boxed">
4747
<a class="navbar-link">
48-
{{theme_external_nav_links_dropdown_title}}
48+
{{dropdown_title}}
4949
</a>
5050
<div class="navbar-dropdown top-navbar">
51-
{%- for (name, link) in theme_external_nav_links_dropdown %}
51+
{%- for (name, link) in dropdown_links %}
52+
{%- if link.startswith('http') %}
5253
<a class="navbar-item" href="{{link}}" target="_blank">
54+
{%- else %}
55+
<a class="navbar-item" href="{{pathto(link)}}" target="_blank">
56+
{%- endif %}
5357
{{name}}
5458
</a>
55-
{%- endfor %}
59+
{%- endfor %}
5660
</div>
5761
</div>
62+
{%- endfor %}
5863
{%- endif %}
5964
</div>
6065

tensorly_sphinx_theme/theme.conf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,5 @@ globaltoc_maxdepth = 2
1111
github_url =
1212
google_analytics =
1313
nav_links =
14-
external_nav_links =
15-
external_nav_links_dropdown_title =
16-
external_nav_links_dropdown =
14+
nav_dropdowns =
1715
searchbar_text = Search the doc

0 commit comments

Comments
 (0)