Skip to content

Commit

Permalink
[5.x] Add check if api is used
Browse files Browse the repository at this point in the history
  • Loading branch information
christophstockinger committed Dec 3, 2024
1 parent aa23ed1 commit 72b57b6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Fieldtypes/Bard/LinkMark.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 72b57b6

Please sign in to comment.