I've a node, which is linked to a sub menu in the main navigation. I would like to get the url and title for the parent menu of the sub menu selected.
I've used it, but it is not working. I'm trying to use it in hook_node_view()
$node_id = $entity->id();
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
$result = $menu_link_manager->loadLinksByRoute('entity.node.canonical', array('node' => $node_id));
$build['result'] = $result;
kint($result);
In twig, I'm calling it as
{{ content.result }}
But it is not working..