dsfr4drupal-1.x-dev/components/link/link.twig
components/link/link.twig
{% set attributes = attributes|default(create_attribute()) %}
{% set icon_position = icon_position|default('left') %}
{% set url = url|default(attributes.href) %}
{% set attributes = attributes.addClass('fr-link') %}
{% if variant and variant != 'md' %}
{% set attributes = attributes.addClass('fr-link--' ~ variant) %}
{% endif %}
{% if is_close %}
{% set attributes = attributes.addClass('fr-link--close') %}
{% endif %}
{% if is_download %}
{% set attributes = attributes.addClass('fr-link--download') %}
{% set attributes = attributes.setAttribute('download', true) %}
{% if file_assess %}
{% set attributes = attributes.setAttribute('data-fr-assess-file', 'true') %}
{% endif %}
{% endif %}
{% if icon %}
{% set attributes = attributes.addClass('fr-icon-' ~ icon) %}
{% if icon_position %}
{% set attributes = attributes.addClass('fr-link--icon-' ~ icon_position) %}
{% endif %}
{% endif %}
{% if is_external %}
{% set attributes = attributes.setAttribute('rel', 'noopener') %}
{% if not force_internal %}
{% set attributes = attributes.setAttribute('target', '_blank') %}
{% endif %}
{% endif %}
{% if target %}
{% set attributes = attributes.setAttribute('target', '_' ~ target) %}
{% endif %}
{% if title %}
{% set attributes = attributes.setAttribute('title', title) %}
{% endif %}
{% if detail %}
{% set label %}
{{ label }} <span class="fr-link__detail">{{ detail }}</span>
{% endset %}
{% endif %}
{{ link(label, url, attributes) }}
