Skip to content

Commit

Permalink
generate: Open external links in new tab
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Graber <[email protected]>
  • Loading branch information
stgraber committed Oct 7, 2023
1 parent 5aa7a3a commit 13abb48
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 7 additions & 4 deletions generate
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,25 @@ def gen_menu(structure, override, prefix):

if len(item['menu']) == 1:
# Simple menu entry
menu.append((item['path'], item['menu'][0]))
menu.append((item['path'], item['menu'][0],
item.get("generator", "") == "link"))
else:
# Drop-down menu
if sub_menu_title != item['menu'][0]:
if sub_menu:
menu.append((sub_menu, sub_menu_title))
menu.append((sub_menu, sub_menu_title, False))
sub_menu = []
sub_menu_title = item['menu'][0]

# Simple menu entry
sub_menu.append((item['path'], item['menu'][-1]))
sub_menu.append((item['path'], item['menu'][-1],
item.get("generator", "") == "link"))

# Process the last drop-down menu
if structure and sub_menu_title:
if sub_menu:
menu.append((sub_menu, sub_menu_title))
menu.append((sub_menu, sub_menu_title,
item.get("generator", "") == "link"))

return menu

Expand Down
6 changes: 5 additions & 1 deletion templates/common/header.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ <h3 class="p-heading--5 p-navigation__link u-no-margin--bottom">{{ sub_entry[1]
</li>
{% else %}
<li>
<a href="{{ sub_entry[0] }}" class="p-navigation__dropdown-item{% if page_menu[1] == sub_entry[1] %} is-selected{% endif %}">{{ sub_entry[1] }}</a>
{% if sub_entry[2] %}
<a href="{{ sub_entry[0] }}" target="_blank" class="p-navigation__dropdown-item{% if page_menu[1] == sub_entry[1] %} is-selected{% endif %}">{{ sub_entry[1] }}</a>
{% else %}
<a href="{{ sub_entry[0] }}" class="p-navigation__dropdown-item{% if page_menu[1] == sub_entry[1] %} is-selected{% endif %}">{{ sub_entry[1] }}</a>
{% endif %}
</li>
{% endif %}
{% endfor %}
Expand Down

0 comments on commit 13abb48

Please sign in to comment.