This commit adds support for reusing existing character images from exis
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
// Comic-themed words for generating beautiful slugs
|
||||
const COMIC_WORDS = {
|
||||
heroes: ['super', 'hero', 'captain', 'iron', 'spider', 'bat', 'wonder', 'flash', 'green', 'black', 'deadpool', 'wolverine', 'hulk', 'thor', 'captain'],
|
||||
villains: ['dark', 'shadow', 'evil', 'master', 'doctor', 'joker', 'lex', 'magneto', 'thanos', 'loki', 'venom', 'bane', 'riddler'],
|
||||
actions: ['strike', 'force', 'power', 'legend', 'saga', 'quest', 'battle', 'warrior', 'guardian', 'defender', 'avenger', 'justice'],
|
||||
settings: ['city', 'world', 'universe', 'realm', 'dimension', 'galaxy', 'earth', 'mars', 'moon', 'space', 'future', 'past'],
|
||||
styles: ['noir', 'manga', 'comic', 'graphic', 'epic', 'legend', 'myth', 'tale', 'story', 'chronicle', 'adventure']
|
||||
};
|
||||
|
||||
const NUMBERS = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
|
||||
|
||||
export function generateComicSlug(): string {
|
||||
// Generate 2-3 random words from different categories
|
||||
const categories = Object.keys(COMIC_WORDS) as (keyof typeof COMIC_WORDS)[];
|
||||
const selectedCategories = categories.sort(() => 0.5 - Math.random()).slice(0, 2 + Math.floor(Math.random() * 2));
|
||||
|
||||
const words: string[] = [];
|
||||
selectedCategories.forEach(category => {
|
||||
const categoryWords = COMIC_WORDS[category];
|
||||
const randomWord = categoryWords[Math.floor(Math.random() * categoryWords.length)];
|
||||
words.push(randomWord);
|
||||
});
|
||||
|
||||
// Add a random number word sometimes
|
||||
if (Math.random() > 0.7) {
|
||||
const randomNumber = NUMBERS[Math.floor(Math.random() * NUMBERS.length)];
|
||||
words.push(randomNumber);
|
||||
}
|
||||
|
||||
// Generate short random string (4-5 chars)
|
||||
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||
const randomString = Array.from({ length: 4 + Math.floor(Math.random() * 2) }, () =>
|
||||
chars[Math.floor(Math.random() * chars.length)]
|
||||
).join('');
|
||||
|
||||
// Combine words with hyphens and add random string
|
||||
const slugWords = words.join('-');
|
||||
return `${slugWords}-${randomString}`;
|
||||
}
|
||||
|
||||
export function slugify(text: string): string {
|
||||
return text
|
||||
.toLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, '-')
|
||||
.replace(/(^-|-$)/g, '');
|
||||
}
|
||||
Reference in New Issue
Block a user