views – Display teasers in a details element

I have a view which is displaying nodes in the teaser view mode.

I would like to to have all those teasers inserted into a details HTML element.

This is the code I am using.

function mymodule_preprocess_node(&$variables) {
  $variables('content') = (
    '#type' => 'details',
    '#title' => $variables('label')(0)('#context')('value'),
    'content'=>$variables('content'),
  );
}

I tried to use the following code without success.

function mymodule_preprocess_node(&$variables) {
  $variables('content') = (
    '#type' => 'details',
    '#title' => $variables('label')(0)('#context')('value'),
    'content' => (
      '#theme' => 'node',
      '#node'=> $variables('node'),
      '#view_mode'=> 'teaser',
    ),
  );
}

The idea was to reuse the teaser template. When doing this, the site is taking too much time to display the page. (In fact, it doesn’t display it.)

The same happens when I use 'content' =>Drupal::entityTypeManager()->getViewBuilder('node')->view($node,'teaser').

As only the first snippet works, I added a template suggestion for the details element in order to re-create the layout of the teaser template.

Is it the best approach?