Is it possible to alter html_head using hook_page_attachments_alter()
per node? I need to attach different <script>
tags to a list of nodes. I am able to add it to each node, but all gets overridden with the last alteration.
$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties(['type' => 'faq_page', 'status' => 1]);
foreach($nodes as $node) {
$description = [
[
'#tag' => 'script',
],
// …
$page['#attached']['html_head'][] = [$description, 'description];
}