-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
25 lines (23 loc) · 851 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { router, usePage } from "@inertiajs/vue3";
import { computed } from "vue";
const VuetifyInertiaLink = {
install(app) {
app.component("RouterLink", {
useLink(props) {
const href = props.to.value;
const currentUrl = computed(() => usePage().url);
return {
route: computed(() => ({ href })),
isActive: computed(() => currentUrl.value.startsWith(href)),
isExactActive: computed(() => href === currentUrl),
navigate(e) {
if (e.shiftKey || e.metaKey || e.ctrlKey) return;
e.preventDefault();
router.visit(href);
}
};
}
});
}
};
export default VuetifyInertiaLink;