diff --git a/composer.json b/composer.json index 9c9b117..b50bd74 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,10 @@ "autoload": { "psr-4": { "Rapidez\\Statamic\\": "src" - } + }, + "files": [ + "src/Helpers/UrlHelper.php" + ] }, "config": { "sort-packages": true, diff --git a/resources/views/components/nav-layer.blade.php b/resources/views/components/nav-layer.blade.php new file mode 100644 index 0000000..9bde955 --- /dev/null +++ b/resources/views/components/nav-layer.blade.php @@ -0,0 +1,56 @@ +@props(['id', 'children', 'title' => __('Menu'), 'hasParent' => false, 'tag' => 'form', 'parentUrl' => '']) +@slots(['headerbutton']) +@php + $baseUrl = \Statamic\Facades\Site::current()->absoluteUrl(); +@endphp + + +
+ @include('rapidez-statamic::navigation.header-button') +
+
+
+ + {{ $slot }} +
+
diff --git a/resources/views/navigation/header-button.blade.php b/resources/views/navigation/header-button.blade.php new file mode 100644 index 0000000..c3401bd --- /dev/null +++ b/resources/views/navigation/header-button.blade.php @@ -0,0 +1 @@ +{{-- This is shown on the first slideover of the mobile menu, this is empty by default but can be overridden --}} diff --git a/resources/views/navigation/nav.blade.php b/resources/views/navigation/nav.blade.php new file mode 100644 index 0000000..5a48011 --- /dev/null +++ b/resources/views/navigation/nav.blade.php @@ -0,0 +1,60 @@ +@props(['nav' => 'nav:main', 'mobileNav' => 'nav:main']) +@php + // This combines multiple navigations into one for desktop and mobile seperately, only neccessary if you have multiple navigations + $navData = array_merge(...Arr::map(Arr::wrap($nav), fn($item) => Statamic::tag($item)->fetch())); + $mobileNavData = array_merge(...Arr::map(Arr::wrap($mobileNav), fn($item) => Statamic::tag($item)->fetch())); +@endphp + +@php + $baseUrl = \Statamic\Facades\Site::current()->absoluteUrl(); +@endphp + diff --git a/src/Helpers/UrlHelper.php b/src/Helpers/UrlHelper.php new file mode 100644 index 0000000..3ec80f5 --- /dev/null +++ b/src/Helpers/UrlHelper.php @@ -0,0 +1,16 @@ +value()['url_path'] ?? false)) { + return $baseUrl . '/' . $item[$type]->value()['url_path']; + } + } + + return $item['url'] ?? ''; + } +}