You are here

function humanstxt_page_attachments in Humans.txt 8

Same name and namespace in other branches
  1. 2.x humanstxt.module \humanstxt_page_attachments()

Implements hook_page_attachments().

File

./humanstxt.module, line 54
Humanstxt module file.

Code

function humanstxt_page_attachments(array &$attachments) {

  // Check the current value of the config item to insert the link.
  if (\Drupal::config('humanstxt.settings')
    ->get('display_link')) {

    // Add a new head link tag.
    // @see \Drupal\render_attached_test\Controller\RenderAttachedTestController::htmlHeaderLink
    $attachments['#attached']['html_head_link'][] = [
      [
        'rel' => 'author',
        'type' => 'text/plain',
        'hreflang' => 'x-default',
        'href' => Url::fromRoute('humanstxt.content', [], [
          'absolute' => TRUE,
        ])
          ->toString(),
      ],
      TRUE,
    ];
  }
}