You are here

function simple_styleguide_page_attachments_alter in Simple Style Guide 8

Implements hook_page_attachments_alter().

Prevent styleguide from being indexed even though permissions alone should prevent this from happening.

File

./simple_styleguide.module, line 63
Contains simple_styleguide.module.

Code

function simple_styleguide_page_attachments_alter(array &$attachments) {
  $route_name = \Drupal::routeMatch()
    ->getRouteName();
  if (in_array($route_name, [
    'simple_styleguide.controller',
  ])) {

    // Set meta tag for robots.
    $robots = [
      '#type' => 'html_tag',
      '#tag' => 'meta',
      '#attributes' => [
        'name' => 'robots',
        'content' => 'noindex, nofollow',
      ],
    ];
    $attachments['#attached']['html_head'][] = [
      $robots,
      'robots',
    ];
  }
}