From 72b57b6493a05fb7cd63bff18cac52671f030843 Mon Sep 17 00:00:00 2001 From: Christoph Stockinger Date: Tue, 3 Dec 2024 09:47:22 +0100 Subject: [PATCH] [5.x] Add check if api is used --- src/Fieldtypes/Bard/LinkMark.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Fieldtypes/Bard/LinkMark.php b/src/Fieldtypes/Bard/LinkMark.php index 421bfd440c..3c7538529e 100644 --- a/src/Fieldtypes/Bard/LinkMark.php +++ b/src/Fieldtypes/Bard/LinkMark.php @@ -4,6 +4,7 @@ use Statamic\Contracts\Entries\Entry; use Statamic\Facades\Data; +use Statamic\Facades\Site; use Statamic\Support\Str; use Tiptap\Marks\Link; @@ -64,8 +65,13 @@ protected function convertHref($href) return ''; } - if ($item instanceof Entry) { - return $item->url(); + $isRestApi = config('statamic.api.enabled', false) && Str::startsWith(request()->path(), config('statamic.api.route', 'api')); + $isGraphqlApi = config('statamic.graphql.enabled', false) && Str::startsWith(request()->path(), 'graphql'); + + $isApi = $isRestApi || $isGraphqlApi; + + if (! $isApi && $item instanceof Entry) { + return ($item->in(Site::current()->handle()) ?? $item)->url(); } return $item->url();