Support defining LINKS that open in the same window

Currently all LINKS open in a new window (target="_blank"), but in
some cases it's desirable to open them in the same window. For example
I use it for linking to categories and tags:

LINKS = (
    ('Categories', SITEURL+'/categories#categories', False),
    ('Tags', SITEURL+'/tags#tags', False),
)

Old format and experience is still supported, this is
backwards-compatible.
This commit is contained in:
Fidel Ramos 2019-10-19 16:54:40 +00:00
parent 4180f7e9c1
commit 90e3ee38ff
No known key found for this signature in database
GPG key ID: 64490E0A752C21C4

View file

@ -116,8 +116,14 @@
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% for name, link in LINKS %} {% for link_tuple in LINKS %}
<li><a href="{{ link }}" target="_blank">{{ name }}</a></li> {% if link_tuple|length == 2 %}
{% set name, link = link_tuple %}
<li><a href="{{ link }}" target="_blank">{{ name }}</a></li>
{% else %}
{% set name, link, new_window = link_tuple %}
<li><a href="{{ link }}" {% if new_window %}target="_blank"{% endif %}>{{ name }}</a></li>
{% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
</nav> </nav>