Skip to content

Commit b3401e3

Browse files
Merge pull request #178 from laravel/replace-ziggy-with-wayfinder
Replace Ziggy with Wayfinder
2 parents 79345b1 + 74290c3 commit b3401e3

34 files changed

+134
-150
lines changed

.github/workflows/tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ jobs:
4343
- name: Generate Application Key
4444
run: php artisan key:generate
4545

46-
- name: Publish Ziggy Configuration
47-
run: php artisan ziggy:generate
48-
4946
- name: Build Assets
5047
run: npm run build
5148

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
/public/storage
77
/storage/*.key
88
/storage/pail
9+
/resources/js/actions
10+
/resources/js/routes
11+
/resources/js/wayfinder
912
/vendor
1013
.env
1114
.env.backup

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
resources/js/components/ui/*
2-
resources/js/ziggy.js
32
resources/views/mail/*

app/Http/Middleware/HandleInertiaRequests.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Illuminate\Foundation\Inspiring;
66
use Illuminate\Http\Request;
77
use Inertia\Middleware;
8-
use Tighten\Ziggy\Ziggy;
98

109
class HandleInertiaRequests extends Middleware
1110
{
@@ -46,10 +45,6 @@ public function share(Request $request): array
4645
'auth' => [
4746
'user' => $request->user(),
4847
],
49-
'ziggy' => [
50-
...(new Ziggy)->toArray(),
51-
'location' => $request->url(),
52-
],
5348
'sidebarOpen' => ! $request->hasCookie('sidebar_state') || $request->cookie('sidebar_state') === 'true',
5449
];
5550
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"inertiajs/inertia-laravel": "^2.0",
1414
"laravel/framework": "^12.0",
1515
"laravel/tinker": "^2.10.1",
16-
"tightenco/ziggy": "^2.4"
16+
"laravel/wayfinder": "^0.1.9"
1717
},
1818
"require-dev": {
1919
"fakerphp/faker": "^1.23",

package-lock.json

Lines changed: 8 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
},
1212
"devDependencies": {
1313
"@eslint/js": "^9.19.0",
14+
"@laravel/vite-plugin-wayfinder": "^0.1.3",
1415
"@tailwindcss/vite": "^4.1.11",
1516
"@types/node": "^22.13.5",
1617
"@vitejs/plugin-vue": "^6.0.0",
@@ -38,8 +39,7 @@
3839
"tailwind-merge": "^3.2.0",
3940
"tailwindcss": "^4.1.1",
4041
"tw-animate-css": "^1.2.5",
41-
"vue": "^3.5.13",
42-
"ziggy-js": "^2.4.2"
42+
"vue": "^3.5.13"
4343
},
4444
"optionalDependencies": {
4545
"@rollup/rollup-linux-x64-gnu": "4.9.5",

resources/js/app.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { createInertiaApp } from '@inertiajs/vue3';
44
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
55
import type { DefineComponent } from 'vue';
66
import { createApp, h } from 'vue';
7-
import { ZiggyVue } from 'ziggy-js';
87
import { initializeTheme } from './composables/useAppearance';
98

109
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
@@ -15,7 +14,6 @@ createInertiaApp({
1514
setup({ el, App, props, plugin }) {
1615
createApp({ render: () => h(App, props) })
1716
.use(plugin)
18-
.use(ZiggyVue)
1917
.mount(el);
2018
},
2119
progress: {

resources/js/components/AppHeader.vue

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from '@/co
1010
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
1111
import UserMenuContent from '@/components/UserMenuContent.vue';
1212
import { getInitials } from '@/composables/useInitials';
13+
import { dashboard } from '@/routes';
1314
import type { BreadcrumbItem, NavItem } from '@/types';
14-
import { Link, usePage } from '@inertiajs/vue3';
15+
import { InertiaLinkProps, Link, usePage } from '@inertiajs/vue3';
1516
import { BookOpen, Folder, LayoutGrid, Menu, Search } from 'lucide-vue-next';
1617
import { computed } from 'vue';
1718
@@ -26,16 +27,17 @@ const props = withDefaults(defineProps<Props>(), {
2627
const page = usePage();
2728
const auth = computed(() => page.props.auth);
2829
29-
const isCurrentRoute = computed(() => (url: string) => page.url === url);
30+
const isCurrentRoute = computed(() => (url: NonNullable<InertiaLinkProps['href']>) => page.url === (typeof url === 'string' ? url : url.url));
3031
3132
const activeItemStyles = computed(
32-
() => (url: string) => (isCurrentRoute.value(url) ? 'text-neutral-900 dark:bg-neutral-800 dark:text-neutral-100' : ''),
33+
() => (url: NonNullable<InertiaLinkProps['href']>) =>
34+
isCurrentRoute.value(typeof url === 'string' ? url : url.url) ? 'text-neutral-900 dark:bg-neutral-800 dark:text-neutral-100' : '',
3335
);
3436
3537
const mainNavItems: NavItem[] = [
3638
{
3739
title: 'Dashboard',
38-
href: '/dashboard',
40+
href: dashboard(),
3941
icon: LayoutGrid,
4042
},
4143
];
@@ -88,7 +90,7 @@ const rightNavItems: NavItem[] = [
8890
<a
8991
v-for="item in rightNavItems"
9092
:key="item.title"
91-
:href="item.href"
93+
:href="typeof item.href === 'string' ? item.href : item.href?.url"
9294
target="_blank"
9395
rel="noopener noreferrer"
9496
class="flex items-center space-x-2 text-sm font-medium"
@@ -102,7 +104,7 @@ const rightNavItems: NavItem[] = [
102104
</Sheet>
103105
</div>
104106

105-
<Link :href="route('dashboard')" class="flex items-center gap-x-2">
107+
<Link :href="dashboard()" class="flex items-center gap-x-2">
106108
<AppLogo />
107109
</Link>
108110

@@ -139,7 +141,11 @@ const rightNavItems: NavItem[] = [
139141
<Tooltip>
140142
<TooltipTrigger>
141143
<Button variant="ghost" size="icon" as-child class="group h-9 w-9 cursor-pointer">
142-
<a :href="item.href" target="_blank" rel="noopener noreferrer">
144+
<a
145+
:href="typeof item.href === 'string' ? item.href : item.href?.url"
146+
target="_blank"
147+
rel="noopener noreferrer"
148+
>
143149
<span class="sr-only">{{ item.title }}</span>
144150
<component :is="item.icon" class="size-5 opacity-80 group-hover:opacity-100" />
145151
</a>

resources/js/components/AppSidebar.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import NavFooter from '@/components/NavFooter.vue';
33
import NavMain from '@/components/NavMain.vue';
44
import NavUser from '@/components/NavUser.vue';
55
import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem } from '@/components/ui/sidebar';
6+
import { dashboard } from '@/routes';
67
import { type NavItem } from '@/types';
78
import { Link } from '@inertiajs/vue3';
89
import { BookOpen, Folder, LayoutGrid } from 'lucide-vue-next';
@@ -11,7 +12,7 @@ import AppLogo from './AppLogo.vue';
1112
const mainNavItems: NavItem[] = [
1213
{
1314
title: 'Dashboard',
14-
href: '/dashboard',
15+
href: dashboard(),
1516
icon: LayoutGrid,
1617
},
1718
];
@@ -36,7 +37,7 @@ const footerNavItems: NavItem[] = [
3637
<SidebarMenu>
3738
<SidebarMenuItem>
3839
<SidebarMenuButton size="lg" as-child>
39-
<Link :href="route('dashboard')">
40+
<Link :href="dashboard()">
4041
<AppLogo />
4142
</Link>
4243
</SidebarMenuButton>

0 commit comments

Comments
 (0)