SPB Git forge

spb/rareindex

Public
54commits 1branches 0releases
7.1 MBsize
maindefault branch
10 days agolast push
TypeScript 61.9% HTML 37.2% SQL 0.7%
1016 B · 24 lines typescript
Raw Blame History
1import { getCategory, categoryPath, FAMILIES, CATEGORIES, getGrader, humanize } from '@rareindex/taxonomy';23export { getCategory, categoryPath, FAMILIES, CATEGORIES, getGrader, humanize };45export function catName(slug: string | null | undefined): string {6  if (!slug) return '—';7  return getCategory(slug)?.name ?? humanize(slug);8}910export function familyName(slug: string | null | undefined): string {11  if (!slug) return '—';12  const c = getCategory(slug);13  return c ? (getCategory(c.familySlug)?.name ?? c.name) : humanize(slug);14}1516export function gradeLabel(grader: string | null | undefined, grade: string | null | undefined): string | null {17  if (!grader || grader === 'raw') return grade ? grade : grader === 'raw' ? 'Raw' : null;18  return `${getGrader(grader)?.name ?? grader.toUpperCase()} ${grade ?? ''}`.trim();19}2021export function categoryCrumbs(slug: string): Array<{ label: string; href: string }> {22  return categoryPath(slug).map((c) => ({ label: c.name, href: `/markets/${c.slug}` }));23}24