mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 05:13:33 -06:00
Add configuration options for opening external links in new tab (#1360)
I've whipped up a solution that solves #1103. I've added a config option `nav_external_links_new_tab`, which is off by default. When turned on, it'll pop external nav links into a new tab. The idea was borrowed from how [aux_nav.html](https://github.com/just-the-docs/just-the-docs/blob/main/_includes/components/aux_nav.html) does it with `aux_links_new_tab`. --------- Co-authored-by: Matt Wang <matt@matthewwang.me>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
Results in: HTML for the side bar.
|
||||
Includes:
|
||||
title.html, components/site_nav.html, nav_footer_custom.html
|
||||
Overwrites:
|
||||
Overwrites:
|
||||
nav_footer_custom.
|
||||
Should not be cached, because nav_footer_custom.html might depend on page.
|
||||
{%- endcomment -%}
|
||||
@@ -16,9 +16,9 @@
|
||||
<svg viewBox="0 0 24 24" class="icon" aria-hidden="true"><use xlink:href="#svg-menu"></use></svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
{% include_cached components/site_nav.html %}
|
||||
|
||||
|
||||
{% capture nav_footer_custom %}
|
||||
{%- include nav_footer_custom.html -%}
|
||||
{% endcapture %}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
Results in: HTML for the site-nav.
|
||||
Includes:
|
||||
components/nav.html
|
||||
Overwrites:
|
||||
Overwrites:
|
||||
pages_top_size, collections_size, collection_entry,
|
||||
collection_key, collection_value, collection.
|
||||
{%- endcomment -%}
|
||||
@@ -22,7 +22,11 @@
|
||||
<ul class="nav-list">
|
||||
{%- for node in site.nav_external_links -%}
|
||||
<li class="nav-list-item external">
|
||||
<a href="{{ node.url | absolute_url }}" class="nav-list-link external">
|
||||
<a href="{{ node.url | absolute_url }}" class="nav-list-link external"
|
||||
{% if node.opens_in_new_tab or (node.opens_in_new_tab == nil and site.nav_external_links_new_tab) %}
|
||||
target="_blank" rel="noopener noreferrer"
|
||||
{% endif %}
|
||||
>
|
||||
{{ node.title }}
|
||||
{% unless node.hide_icon %}<svg viewBox="0 0 24 24" aria-labelledby="svg-external-link-title"><use xlink:href="#svg-external-link"></use></svg>{% endunless %}
|
||||
</a>
|
||||
|
Reference in New Issue
Block a user