diff --git a/modules/next/src/Entity/NextSite.php b/modules/next/src/Entity/NextSite.php index 098f06a2..9a5f7f6a 100644 --- a/modules/next/src/Entity/NextSite.php +++ b/modules/next/src/Entity/NextSite.php @@ -245,6 +245,15 @@ public function getPreviewUrlForEntity(EntityInterface $entity): Url { $query['resourceVersion'] = $resource_version; } + // Add workspace information if available + if (\Drupal::moduleHandler()->moduleExists('workspaces')) { + $workspace_manager = \Drupal::service('workspaces.manager'); + $active_workspace = $workspace_manager->getActiveWorkspace(); + if ($active_workspace) { + $query['workspace'] = $active_workspace->id(); + } + } + $preview_url->setOption('query', $query); return $preview_url;