Implements hook_preprocess_HOOK() for HTML document templates.
function node_preprocess_html(&$variables) : void { // If on an individual node page or node preview page, add the node type to // the body classes. if (($node = \Drupal::routeMatch()->getParameter('node')) || ($node = \Drupal::routeMatch()->getParameter('node_preview'))) { if ($node instanceof NodeInterface) { $variables['node_type'] = $node->getType(); } } }