diff --git a/templates/base.html b/templates/base.html index 4fdbf8a..357ceed 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,14 +1,15 @@ +{% import "macros/add_comments.html" as macros_add_comments %} +{% import "macros/cards_pages.html" as macros_cards_pages %} +{% import "macros/content.html" as macros_content %} +{% import "macros/create_history_url.html" as macros_create_history_url %} +{% import "macros/format_date.html" as macros_format_date %} {% import "macros/list_posts.html" as macros_list_posts %} -{% import "macros/page_header.html" as macros_page_header %} {% import "macros/page_desc.html" as macros_page_desc %} -{% import "macros/content.html" as macros_content %} -{% import "macros/cards_pages.html" as macros_cards_pages %} -{% import "macros/set_title.html" as macros_set_title %} +{% import "macros/page_header.html" as macros_page_header %} {% import "macros/paginate.html" as macros_paginate %} -{% import "macros/format_date.html" as macros_format_date %} -{% import "macros/add_comments.html" as macros_add_comments %} +{% import "macros/rel_attributes.html" as macros_rel_attributes %} +{% import "macros/set_title.html" as macros_set_title %} {% import "macros/table_of_contents.html" as macros_toc %} -{% import "macros/create_history_url.html" as macros_create_history_url %} {%- for page in pages %}
{% if page.extra.link_to %} - + {% endif %} {% if page.extra.local_image %} {% set meta = get_image_metadata(path=page.extra.local_image, allow_missing=true) %} @@ -21,7 +29,7 @@

{% if page.extra.link_to %} - {{page.title}} + {{page.title}} {% else %} {{page.title}} {% endif %} diff --git a/templates/macros/content.html b/templates/macros/content.html index 4c42835..9a45f5b 100644 --- a/templates/macros/content.html +++ b/templates/macros/content.html @@ -1,6 +1,14 @@ {% macro content(page) %} -{% set separator = config.extra.separator | default(value="•") %} +{%- set separator = config.extra.separator | default(value="•") -%} + +{%- 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 -%}
@@ -35,7 +43,7 @@ {# Show link to remote changes if enabled #} {% set show_remote_changes = config.extra.show_remote_changes | default(value=true) %} {% if config.extra.remote_repository_url and show_remote_changes %} -
  •  {{ separator }} {%- if lang != config.default_language -%}{{ trans(key="see_changes" | safe, lang=lang) }}{% else %}See changes{%- endif -%}
  • +
  •  {{ separator }} {%- if lang != config.default_language -%}{{ trans(key="see_changes" | safe, lang=lang) }}{% else %}See changes{%- endif -%}
  • {% endif %} {% endif %} diff --git a/templates/macros/rel_attributes.html b/templates/macros/rel_attributes.html new file mode 100644 index 0000000..0fab687 --- /dev/null +++ b/templates/macros/rel_attributes.html @@ -0,0 +1,19 @@ +{% macro rel_attributes() %} + +{%- set rel_attributes = [] -%} +{%- if config.markdown.external_links_target_blank -%} + {%- set rel_attributes = rel_attributes | concat(with="noopener") -%} +{%- endif -%} +{# https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel#nofollow #} +{# This is ignored, as it doesn't make sense to set `nofollow` on projects or social links. #} +{# {%- 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 external_links %} diff --git a/templates/partials/footer.html b/templates/partials/footer.html index 439d089..7f28de0 100644 --- a/templates/partials/footer.html +++ b/templates/partials/footer.html @@ -1,4 +1,13 @@ -{% set separator = config.extra.separator | default(value="•") %} +{%- set separator = config.extra.separator | default(value="•") -%} + +{%- 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 -%} +