Skip to content

Commit 3cf198b

Browse files
Include the base url in menu item urls (#170)
1 parent 26e2539 commit 3cf198b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/RapidezStatamic.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Rapidez\Statamic\Exceptions\NavException;
1010
use Statamic\Structures\Page;
1111
use Statamic\Facades\Site;
12+
use Illuminate\Support\Str;
1213

1314
class RapidezStatamic
1415
{
@@ -56,10 +57,10 @@ protected function buildTree(array $items, string $nav): array
5657
}
5758

5859
$item['url'] = $this->determineEntryUrl($item['entry_id']->augmentable(), $nav);
59-
60+
6061
$tree[] = $item;
6162
}
62-
63+
6364
return $tree;
6465
}
6566

@@ -92,12 +93,15 @@ public function determineEntryUrl(Entry|Page|string $entry, string $nav = 'globa
9293

9394
if (!isset($entry->{$linkedRunwayResourceKey}['url_path'])) {
9495
$this->navCache[$nav][$entry->id()] = '';
95-
96+
9697
return '';
9798
}
9899

99-
$this->navCache[$nav][$entry->id()] = '/' . $entry->{$linkedRunwayResourceKey}['url_path'] . $suffix;
100-
100+
$siteUrl = Str::finish(Site::current()->absoluteUrl(), '/');
101+
$urlPath = $entry->{$linkedRunwayResourceKey}['url_path'] . $suffix;
102+
103+
$this->navCache[$nav][$entry->id()] = $siteUrl . $urlPath;
104+
101105
Cache::forever($cacheKey, $this->navCache[$nav]);
102106
}
103107

0 commit comments

Comments
 (0)