bootstrap_italia-8.x-0.x-dev/components/components-2/share/share-this.twig

components/components-2/share/share-this.twig
{#
/**
 * @file
 * Template for share-this component.
 * Docs: https://italia.github.io/bootstrap-italia/docs/esempi/comuni/template-novita-notizia/
 * Latest revision: v2.7.5
 *
 * Parameters:
 * - subject (string) (default: 'Read this news'|t)
 * - description (string) (default: subject)
 * - tags (string) (default: '')
 * - download_url (string) (default: '<current>')
 * - dropdown_label (string) (default 'Share')
 * - dropdown_icon (string) (default 'it-share')
 * - dropdown_icon_color (string) (default 'black')
 * - dropdown_icon_size (string) (default 'sm')
 * - dropdown_button_classes (array) (default: '')
 * - item_icon_color (string) (default 'primary')
 * - item_icon_size (string) (default 'sm')
 *
 * Examples:
   {% include '@bi-bcl/share/share-this.html.twig' with {
      subject: 'Subject',
      description: 'Description'|t,
      download_url: 'https://...'
   } %}
 */
#}
{% apply spaceless %}
  {# Set defaults #}
  {% set _subject = subject ? subject|url_encode : 'Read this news'|t|url_encode %}
  {% set _description = description ? description|url_encode : _subject %}
  {% set _tags = tags ? tags : 'News'|t %}
  {% set _download_href = download_url ? download_url : url('<current>') %}
  {% set _current_url = url('<current>')|render %}
  {% set _dropdown_label = dropdown_label|default('Share'|t) %}
  {% set _dropdown_icon = dropdown_icon|default('it-share') %}
  {% set _dropdown_icon_color = dropdown_icon_color|default('black') %}
  {% set _dropdown_icon_size = dropdown_icon_size|default('sm') %}
  {% set _dropdown_button_classes = dropdown_button_classes|default('') %}
  {% set _item_icon_color = item_icon_color|default('primary') %}
  {% set _item_icon_size = item_icon_size|default('sm') %}

  {% set targets = {
    'facebook': {
      'enable': true,
      'label': 'Facebook',
      'icon': 'it-facebook',
      'description': 'Share on Facebook'|t,
      'targetType': '_blank',
      'targetUrl': 'https://www.facebook.com/sharer/sharer.php?u=' ~ _current_url
    },
    'twitter': {
      'enable': true,
      'label': 'Twitter',
      'icon': 'it-twitter',
      'description': 'Share on Twitter'|t,
      'targetType': '_blank',
      'targetUrl': 'https://twitter.com/intent/tweet?url=' ~ _current_url ~ '&text=' ~ _subject ~ '&hashtags=' ~ _tags
    },
    'linkedin': {
      'enable': true,
      'label': 'Linkedin',
      'icon': 'it-linkedin',
      'description': 'Share on Linkedin'|t,
      'targetType': '_blank',
      'targetUrl': 'https://www.linkedin.com/sharing/share-offsite/?url=' ~ _current_url
    },
    'telegram': {
      'enable': true,
      'label': 'Telegram',
      'icon': 'it-telegram',
      'description': 'Share on Telegram'|t,
      'targetUrl': 'https://t.me/share/url?url=' ~ _current_url ~ '&text=' ~ _subject
    },
    'whatsapp': {
      'enable': true,
      'label': 'Whatsapp',
      'icon': 'it-whatsapp',
      'description': 'Share on Whatsapp'|t,
      'targetType': '_blank',
      'targetUrl': 'https://api.whatsapp.com/send?text=' ~ _subject ~ '%20' ~ _current_url
    },
  } %}

  {# Component #}
  {% include '@bi-bcl/share/share.html.twig' with {
    targets: targets,
    dropdown_label: _dropdown_label,
    dropdown_icon: _dropdown_icon,
    dropdown_icon_color: _dropdown_icon_color,
    dropdown_icon_size: _dropdown_icon_size,
    dropdown_button_classes: _dropdown_button_classes,
    item_icon_color: _item_icon_color,
    item_icon_size: _item_icon_size
  } %}
{% endapply %}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc