import { twMerge } from "tailwind-merge";
import { useParams } from "react-router-dom";

/**
 * Concatenates truthy classes into a space-separated string.
 *
 * @param classes - The classes to concatenate.
 * @returns The concatenated classes.
 */
export const clx = (...classes: (string | boolean | undefined)[]): string => {
  return twMerge(classes.filter(Boolean).join(" "));
};

export const buildPath = (path: string, slug2?: string): string => {
  if (slug2) {
    return `/${slug2}/${path}`;
  } else {
    const { slug } = useParams() as { slug: string };
    return `/${slug}/${path}`;
  }
};
