LINKS_IN_NEW_TAB setting
This setting can be modified to open all LINKS in the same window, open all LINKS in a new window or only only external links in new windows.
This commit is contained in:
parent
56a2a32974
commit
2455759bd8
2 changed files with 15 additions and 3 deletions
|
@ -39,6 +39,12 @@ USE_FOLDER_AS_CATEGORY = False
|
||||||
MAIN_MENU = True
|
MAIN_MENU = True
|
||||||
HOME_HIDE_TAGS = True
|
HOME_HIDE_TAGS = True
|
||||||
|
|
||||||
|
# Valid values for LINKS_IN_NEW_TAB:
|
||||||
|
# * Unset, None, True or any string to open all LINKS in a new window (default)
|
||||||
|
# * 'no', 'none', False or 0 to open all LINKS in the same window
|
||||||
|
# * 'external' to open LINKS to external sites in a new window, internal links in same window
|
||||||
|
LINKS_IN_NEW_TAB = 'external'
|
||||||
|
|
||||||
SOCIAL = (
|
SOCIAL = (
|
||||||
('github', 'https://github.com/alexandrevicenzi/Flex'),
|
('github', 'https://github.com/alexandrevicenzi/Flex'),
|
||||||
('rss', '/blog/feeds/all.atom.xml'),
|
('rss', '/blog/feeds/all.atom.xml'),
|
||||||
|
|
|
@ -107,18 +107,24 @@
|
||||||
{% if pages or LINKS %}
|
{% if pages or LINKS %}
|
||||||
<nav>
|
<nav>
|
||||||
<ul class="list">
|
<ul class="list">
|
||||||
|
{# Open links in new window depending on the LINKS_IN_NEW_TAB setting #}
|
||||||
|
{% macro link_target(link) -%}
|
||||||
|
{% if LINKS_IN_NEW_TAB not in ('no', 'none', false, 0, 'external') or (LINKS_IN_NEW_TAB == "external" and not link.startswith("/") and not link.startswith(SITEURL)) %}
|
||||||
|
target="_blank"
|
||||||
|
{% endif %}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
{% if PAGES_SORT_ATTRIBUTE -%}
|
{% if PAGES_SORT_ATTRIBUTE -%}
|
||||||
{% set pages = pages|sort(attribute=PAGES_SORT_ATTRIBUTE) %}
|
{% set pages = pages|sort(attribute=PAGES_SORT_ATTRIBUTE) %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{% if DISPLAY_PAGES_ON_MENU %}
|
{% if DISPLAY_PAGES_ON_MENU %}
|
||||||
{% for page in pages %}
|
{% for page in pages %}
|
||||||
<li><a href="{{ SITEURL }}/{{ page.url }}{% if not DISABLE_URL_HASH %}#{{ page.slug }}{% endif %}">{{ page.title }}</a></li>
|
<li><a {{ link_target(SITEURL) }} href="{{ SITEURL }}/{{ page.url }}{% if not DISABLE_URL_HASH %}#{{ page.slug }}{% endif %}">{{ page.title }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% for name, link in LINKS %}
|
{% for name, link in LINKS %}
|
||||||
{# Open external links in new window, relative links in the same window #}
|
<li><a {{ link_target(link) }} href="{{ link }}" >{{ name }}</a></li>
|
||||||
<li><a href="{{ link }}" {% if link[0] != '/' and not link.startswith(SITEURL) %}target="_blank"{% endif %}>{{ name }}</a></li>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue