diff --git a/olivesnews.theme b/olivesnews.theme index 094a683..e772581 100755 --- a/olivesnews.theme +++ b/olivesnews.theme @@ -44,6 +44,20 @@ function olivesnews_preprocess_html(&$variables) { 'href' => $variables['olivesnews_path'] . '/css/components/navigation/nav-primary-no-js.css?' . $query_string, ], ]; +// Use routeMatch — this is the modern, preferred way. + $node = \Drupal::routeMatch()->getParameter('node'); + + if ($node instanceof \Drupal\node\NodeInterface) { + // Add a simple node-ID class (most common format today). + $variables['attributes']['class'][] = 'node-' . $node->id(); + + // Optional: Add the classic Drupal 7-style class if you prefer / need it for legacy CSS. + // $variables['attributes']['class'][] = 'page-node-' . $node->id(); + + // Optional extras people often add at the same time: + // $variables['attributes']['class'][] = 'node-type-' . $node->bundle(); + // $variables['attributes']['class'][] = 'node-' . $node->bundle(); + } } @@ -728,3 +742,4 @@ function olivesnews_preprocess_mirador(&$variables) { ]); } */ +