| 1 | /** biome-ignore-all lint/suspicious/noBitwiseOperators: Need it for color magic */ |
| 2 | import { type ClassValue, |
| 3 | import slugify from 'slugify |
| 4 | import { twMerge } |
| 5 | import { slugAlphabet } |
| 6 | |
| 7 | export function cn(... |
| 8 | return twMerge(clsx |
| 9 | } |
| 10 | |
| 11 | export function titleToSlug(title |
| 12 | const slugified = |
| 13 | const slugifiedWithSuffix = |
| 14 | return { |
| 15 | slugified, |
| 16 | slugifiedWithSuffix, |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | export function seedToColor(seed |
| 21 | let hash = |
| 22 | for (let i |
| 23 | hash = seed. |
| 24 | } |
| 25 | |
| 26 | const h = |
| 27 | const s = |
| 28 | const l = |
| 29 | |
| 30 | // HSL to hex |
| 31 | const lNorm = |
| 32 | const sNorm = |
| 33 | const a = |
| 34 | const f = |
| 35 | const k = |
| 36 | const color = |
| 37 | return Math.round |
| 38 | .toString(16) |
| 39 | .padStart(2, ' |
| 40 | } |
| 41 | |
| 42 | return `#${f |
| 43 | } |
| 44 | |
| 45 | export function formatDate(date |
| 46 | return date.toLocaleDateString |
| 47 | month: 'short', |
| 48 | day: 'numeric', |
| 49 | year: 'numeric', |
| 50 | }) |
| 51 | } |
| 52 | |
| 53 | export function stripHtml(html |
| 54 | return html |
| 55 | .replace(/<[^ |
| 56 | .replace(/\s+/ |
| 57 | .trim() |
| 58 | } |