import { data, redirect } from "react-router";
import type { LoaderFunctionArgs } from "react-router";
import { getArtistBySlug } from "~/lib/db.server";

export async function loader({ params }: LoaderFunctionArgs) {
  const artist = getArtistBySlug(params.slug!);
  if (!artist) throw data("Not found", { status: 404 });
  return redirect(`/artists/of/${artist.id}`);
}

export default function ArtistBySlug() {
  return null;
}
