76 lines
1.0 KiB
TypeScript
76 lines
1.0 KiB
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()}`;
|
|
}
|