♻️ refactor: add target_attribute macro
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
{% import "macros/table_of_contents.html" as macros_toc %}
|
||||
{% import "macros/translate.html" as macros_translate %}
|
||||
{% import "macros/series_page.html" as macros_series_page %}
|
||||
{% import "macros/target_attribute.html" as macros_target_attribute %}
|
||||
|
||||
{# Load the internationalisation data for the current language from
|
||||
the .toml files in the user's '/i18n' folder, falling back to the theme's.
|
||||
|
||||
11
themes/tabi/templates/macros/target_attribute.html
Normal file
11
themes/tabi/templates/macros/target_attribute.html
Normal file
@@ -0,0 +1,11 @@
|
||||
{% macro target_attribute(new_tab) %}
|
||||
|
||||
{%- set blank_target = "" -%}
|
||||
|
||||
{%- if new_tab -%}
|
||||
{%- set blank_target = "target=_blank" -%}
|
||||
{%- endif -%}
|
||||
|
||||
{{ blank_target }}
|
||||
|
||||
{% endmacro target_attribute %}
|
||||
@@ -5,11 +5,7 @@
|
||||
|
||||
{%- set rel_attributes = macros_rel_attributes::rel_attributes() | trim -%}
|
||||
|
||||
{%- if config.markdown.external_links_target_blank -%}
|
||||
{%- set blank_target = "target=_blank" -%}
|
||||
{%- else -%}
|
||||
{%- set blank_target = "" -%}
|
||||
{%- endif -%}
|
||||
{%- set blank_target = macros_target_attribute::target_attribute(new_tab=config.markdown.external_links_target_blank) -%}
|
||||
|
||||
{# Debugging #}
|
||||
{# <div><pre>
|
||||
|
||||
@@ -7,11 +7,7 @@
|
||||
{% break %}
|
||||
{% endif %}
|
||||
{# Determine which URL to use, default is page.permalink #}
|
||||
{%- if page.extra.link_to and config.markdown.external_links_target_blank -%}
|
||||
{%- set blank_target = "target=_blank" -%}
|
||||
{%- else -%}
|
||||
{%- set blank_target = "" -%}
|
||||
{%- endif -%}
|
||||
{%- set blank_target = macros_target_attribute::target_attribute(new_tab=config.markdown.external_links_target_blank and page.extra.link_to) -%}
|
||||
|
||||
{% set target_url = page.extra.link_to | default(value=page.permalink) %}
|
||||
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
|
||||
{%- set rel_attributes = macros_rel_attributes::rel_attributes() | trim -%}
|
||||
|
||||
{%- if config.markdown.external_links_target_blank -%}
|
||||
{%- set blank_target = "target=_blank" -%}
|
||||
{%- else -%}
|
||||
{%- set blank_target = "" -%}
|
||||
{%- endif -%}
|
||||
{%- set blank_target = macros_target_attribute::target_attribute(new_tab=config.markdown.external_links_target_blank) -%}
|
||||
|
||||
{#- Feed icon -#}
|
||||
{#- Zola 0.19.0 uses `generate_feeds`. Prior versions use `generate_feed` -#}
|
||||
|
||||
Reference in New Issue
Block a user