Set rel attributes to links (fixes #40)

This commit is contained in:
daudix
2024-07-29 17:18:25 +03:00
parent 40b4198421
commit 7c176c09d2
8 changed files with 38 additions and 13 deletions

View File

@ -0,0 +1,17 @@
{% macro rel_attributes() %}
{%- set rel_attributes = [] -%}
{%- if config.markdown.external_links_target_blank -%}
{%- set rel_attributes = rel_attributes | concat(with="noopener") -%}
{%- endif -%}
{%- if config.markdown.external_links_no_follow -%}
{%- set rel_attributes = rel_attributes | concat(with="nofollow") -%}
{%- endif -%}
{%- if config.markdown.external_links_no_referrer -%}
{%- set rel_attributes = rel_attributes | concat(with="noreferrer") -%}
{%- endif -%}
{# Return the array of rel attributes joined by a space #}
{{- rel_attributes | join(sep=" ") -}}
{% endmacro rel_attributes %}