25 lines
518 B
TypeScript
25 lines
518 B
TypeScript
import type { InertiaLinkProps } from '@inertiajs/react';
|
|
import { clsx } from 'clsx';
|
|
import type { ClassValue } from 'clsx';
|
|
import { twMerge } from 'tailwind-merge';
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs));
|
|
}
|
|
|
|
export function toUrl(url: InertiaLinkProps['href']): string {
|
|
if (!url) {
|
|
return '';
|
|
}
|
|
|
|
if (typeof url === 'string') {
|
|
return url;
|
|
}
|
|
|
|
if (typeof url === 'object' && url !== null && 'url' in url) {
|
|
return url.url as string;
|
|
}
|
|
|
|
return String(url);
|
|
}
|