import { data, Link, useLoaderData } from "react-router"; import type { LoaderFunctionArgs } from "react-router"; import { getBandById, getBandLinks, getBandArtists, getBandRevisions, } from "~/lib/db.server"; import { LINK_TYPE_LABEL } from "~/lib/constants"; export async function loader({ params }: LoaderFunctionArgs) { const band = getBandById(params.uuid!); if (!band) throw data("Not found", { status: 404 }); const links = getBandLinks(band.id); const artists = getBandArtists(band.id); const revisions = getBandRevisions(band.id); return { band, links, artists, latest: revisions[0] ?? null }; } const STATUS_LABEL: Record = { active: "活動中", hiatus: "活動休止", disbanded: "解散", }; export default function BandDetail() { const { band, links, artists, latest } = useLoaderData(); return (

{band.name}

{band.area && {band.area}} {STATUS_LABEL[band.status] ?? band.status}
{band.description && (

{band.description}

)}
履歴 編集
{artists.length > 0 && (

メンバー

    {artists.map((a) => (
  • {a.artist_name} {a.role && ( {a.role} )}
  • ))}
)} {links.length > 0 && (

リンク

)}

/bands/of/{band.id}

/bands/named/{band.slug}

{latest && (

最終更新: {latest.created_at} — {latest.message}

)}
); }