theming – Adding layout builder enabled template suggestions on page-level twig

I want to detect if Layout Builder is enabled (D8), so that I can add a new page and page-level twig templates that will allow a completely different structure for my site – in this case based on Layout Builder’s layouts.

I found this resource :

/**
 * Implements hook_theme_suggestions_HOOK_alter() for page templates.
 * @param array $suggestions
 * @param array $variables
 */
function MY_theme_suggestions_page_alter(array &$suggestions, array $variables) {
  if ($node = Drupal::request()->attributes->get('node')) {
      if(!empty($node) && $node instanceof DrupalnodeNodeInterface) {
          $type = $node->getType();
  
           // Add content type suggestions.
          array_splice($suggestions, 1, 0, 'page__' . $type);

          // Add layout builder enabled template suggestions
          try {
              $entityTypeManager = Drupal::service('entity_type.manager');
              $storage = $entityTypeManager->getStorage('entity_view_display');
              $view_display = $storage->load('node.' . $type . '.default');

              if (!is_null($view_display)) {
                  $layout_builder_enabled = $view_display->getThirdPartySetting('layout_builder', 'enabled');
                  if($layout_builder_enabled) {
                      array_splice($suggestions, 1, 0, 'page__node__layout__' . $type);
                      array_splice($suggestions, 1, 0, 'page__node__layout');
                 }
              }
          } catch (Exception $e) {
              Drupal::logger('type')->error('Error in ifac.theme ifac_theme_suggestions_page_alter' . $e->getMessage());
          }
      }
  }
}

But in my case this code only works for node types “article”.
What can I do to make it work for others node types using layout builder?
Any suggestions?