Files
splitt-the-bill/shared/utils/slug.ts
T
2026-07-01 15:43:18 +02:00

24 lines
955 B
TypeScript

import { customAlphabet } from 'nanoid'
const ADJECTIVES = [
'drunken', 'sleepy', 'grumpy', 'jolly', 'quiet', 'brave', 'clever', 'eager',
'fuzzy', 'gentle', 'happy', 'icy', 'jumpy', 'kind', 'lively', 'mighty',
'noisy', 'orange', 'proud', 'quick', 'rusty', 'silly', 'tidy', 'upbeat',
'vivid', 'witty', 'zesty', 'bold', 'calm', 'dizzy',
]
const NOUNS = [
'wizard', 'tiger', 'otter', 'falcon', 'penguin', 'dragon', 'panda', 'raven',
'walrus', 'yeti', 'badger', 'comet', 'ember', 'fox', 'goose', 'heron',
'igloo', 'jackal', 'koala', 'lemur', 'mango', 'newt', 'oasis', 'puffin',
'quokka', 'robin', 'sloth', 'toucan', 'unicorn', 'viper',
]
const nanoid = customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', 6)
export function generateSlug(): string {
const adjective = ADJECTIVES[Math.floor(Math.random() * ADJECTIVES.length)]
const noun = NOUNS[Math.floor(Math.random() * NOUNS.length)]
return `${adjective}-${noun}-${nanoid()}`
}