✨ feat(HTML): respect external_links_…
config (#126)
This commit is contained in:
parent
9c3e5d3990
commit
b73f7f5d93
@ -1,14 +1,15 @@
|
|||||||
{% 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/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/add_comments.html" as macros_add_comments %}
|
||||||
{% import "macros/table_of_contents.html" as macros_toc %}
|
{% 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/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_desc.html" as macros_page_desc %}
|
||||||
|
{% import "macros/page_header.html" as macros_page_header %}
|
||||||
|
{% import "macros/paginate.html" as macros_paginate %}
|
||||||
|
{% 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 %}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="{{ lang }}" {% if config.extra.default_theme -%}
|
<html lang="{{ lang }}" {% if config.extra.default_theme -%}
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
{% macro cards_pages(pages) %}
|
{% macro cards_pages(pages) %}
|
||||||
|
|
||||||
|
{%- 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 -%}
|
||||||
|
|
||||||
<div class="cards">
|
<div class="cards">
|
||||||
{%- for page in pages %}
|
{%- for page in pages %}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
{% if page.extra.link_to %}
|
{% if page.extra.link_to %}
|
||||||
<a rel="noopener noreferrer" target="_blank" href={{ page.extra.link_to }}>
|
<a rel="{{ rel_attributes }}" {{ blank_target }} href={{ page.extra.link_to }}>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if page.extra.local_image %}
|
{% if page.extra.local_image %}
|
||||||
{% set meta = get_image_metadata(path=page.extra.local_image, allow_missing=true) %}
|
{% set meta = get_image_metadata(path=page.extra.local_image, allow_missing=true) %}
|
||||||
@ -21,7 +29,7 @@
|
|||||||
<div class="card-info">
|
<div class="card-info">
|
||||||
<h1 class="card-title">
|
<h1 class="card-title">
|
||||||
{% if page.extra.link_to %}
|
{% if page.extra.link_to %}
|
||||||
<a rel="noopener noreferrer" target="_blank" href={{ page.extra.link_to }}>{{page.title}}</a>
|
<a rel="{{ rel_attributes }}" {{ blank_target }} href={{ page.extra.link_to }}>{{page.title}}</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href={{ page.permalink }}>{{page.title}}</a>
|
<a href={{ page.permalink }}>{{page.title}}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
{% macro content(page) %}
|
{% 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 -%}
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<article>
|
<article>
|
||||||
@ -35,7 +43,7 @@
|
|||||||
{# Show link to remote changes if enabled #}
|
{# Show link to remote changes if enabled #}
|
||||||
{% set show_remote_changes = config.extra.show_remote_changes | default(value=true) %}
|
{% set show_remote_changes = config.extra.show_remote_changes | default(value=true) %}
|
||||||
{% if config.extra.remote_repository_url and show_remote_changes %}
|
{% if config.extra.remote_repository_url and show_remote_changes %}
|
||||||
<li> {{ separator }} <a href="{{ macros_create_history_url::create_history_url(relative_path=page.relative_path) }}" target="_blank" rel="noopener noreferrer">{%- if lang != config.default_language -%}{{ trans(key="see_changes" | safe, lang=lang) }}{% else %}See changes{%- endif -%}<small> ↗</small></a></li>
|
<li> {{ separator }} <a href="{{ macros_create_history_url::create_history_url(relative_path=page.relative_path) }}" {{ blank_target }} rel="{{ rel_attributes }}">{%- if lang != config.default_language -%}{{ trans(key="see_changes" | safe, lang=lang) }}{% else %}See changes{%- endif -%}<small> ↗</small></a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
19
templates/macros/rel_attributes.html
Normal file
19
templates/macros/rel_attributes.html
Normal file
@ -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 %}
|
@ -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 -%}
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<section>
|
<section>
|
||||||
<nav class="socials nav-navs">
|
<nav class="socials nav-navs">
|
||||||
@ -6,7 +15,7 @@
|
|||||||
<ul>
|
<ul>
|
||||||
{%- if config.generate_feed and config.extra.feed_icon -%}
|
{%- if config.generate_feed and config.extra.feed_icon -%}
|
||||||
<li>
|
<li>
|
||||||
<a rel="noopener noreferrer" target="_blank" class="nav-links no-hover-padding social" href={{ get_url(path=config.feed_filename, lang=lang, trailing_slash=false) | safe }}>
|
<a class="nav-links no-hover-padding social" rel="{{ rel_attributes }}" {{ blank_target }} href={{ get_url(path=config.feed_filename, lang=lang, trailing_slash=false) | safe }}>
|
||||||
<img alt="feed" title="feed" src="{{ get_url(path='/social_icons/rss.svg') }}">
|
<img alt="feed" title="feed" src="{{ get_url(path='/social_icons/rss.svg') }}">
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@ -30,9 +39,9 @@
|
|||||||
|
|
||||||
<li class="{% if email_needs_decoding %}js{% endif %}">
|
<li class="{% if email_needs_decoding %}js{% endif %}">
|
||||||
{%- if email_needs_decoding -%}
|
{%- if email_needs_decoding -%}
|
||||||
<a rel="noopener noreferrer" target="_blank" class="nav-links no-hover-padding social" href="#" data-encoded-email="{{ encoded_email | safe }}">
|
<a class="nav-links no-hover-padding social" href="#" data-encoded-email="{{ encoded_email | safe }}">
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
<a rel="noopener noreferrer" target="_blank" class="nav-links no-hover-padding social" href="mailto:{{ config.extra.email | safe }}">
|
<a class="nav-links no-hover-padding social" href="mailto:{{ config.extra.email | safe }}">
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
<img alt="email" title="email" src="{{ get_url(path='social_icons/email.svg') }}">
|
<img alt="email" title="email" src="{{ get_url(path='social_icons/email.svg') }}">
|
||||||
</a>
|
</a>
|
||||||
@ -41,7 +50,7 @@
|
|||||||
|
|
||||||
{% for social in config.extra.socials %}
|
{% for social in config.extra.socials %}
|
||||||
<li>
|
<li>
|
||||||
<a rel="noopener noreferrer me" target="_blank" class="nav-links no-hover-padding social" href={{ social.url | safe }}>
|
<a class="nav-links no-hover-padding social" rel="{{ rel_attributes }} me" {{ blank_target }} href={{ social.url | safe }}>
|
||||||
<img alt={{ social.name }} title={{ social.name }} src="{{ get_url(path='social_icons/' ~ social.icon ~ '.svg') }}">
|
<img alt={{ social.name }} title={{ social.name }} src="{{ get_url(path='social_icons/' ~ social.icon ~ '.svg') }}">
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@ -68,19 +77,19 @@
|
|||||||
{%- else -%}
|
{%- else -%}
|
||||||
Powered by
|
Powered by
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
<a href="https://www.getzola.org" target="_blank">Zola</a>
|
<a rel="{{ rel_attributes }}" {{ blank_target }} href="https://www.getzola.org">Zola</a>
|
||||||
{%- if lang != config.default_language -%}
|
{%- if lang != config.default_language -%}
|
||||||
{{ trans(key="and" | safe, lang=lang) }}
|
{{ trans(key="and" | safe, lang=lang) }}
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
&
|
&
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
<a href="https://github.com/welpo/tabi" target="_blank">tabi</a>
|
<a rel="{{ rel_attributes }}" {{ blank_target }} href="https://github.com/welpo/tabi">tabi</a>
|
||||||
|
|
||||||
{# Shows link to remote repository if repository is set and `show_remote_source` is not false #}
|
{# Shows link to remote repository if repository is set and `show_remote_source` is not false #}
|
||||||
{% set show_source = config.extra.show_remote_source | default(value=true) %}
|
{% set show_source = config.extra.show_remote_source | default(value=true) %}
|
||||||
{%- if config.extra.remote_repository_url and show_source -%}
|
{%- if config.extra.remote_repository_url and show_source -%}
|
||||||
{{ separator }}
|
{{ separator }}
|
||||||
<a href="{{ config.extra.remote_repository_url }}" target="_blank">
|
<a rel="{{ rel_attributes }}" {{ blank_target }} href="{{ config.extra.remote_repository_url }}">
|
||||||
{%- if lang != config.default_language -%}
|
{%- if lang != config.default_language -%}
|
||||||
{{ trans(key="site_source" | safe, lang=lang) }}
|
{{ trans(key="site_source" | safe, lang=lang) }}
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user