This commit adds support for reusing existing character images from exis

This commit is contained in:
Riccardo Giorato
2025-12-23 13:43:35 +01:00
parent fbcac53de1
commit ff25be7c85
17 changed files with 895 additions and 155 deletions
+46
View File
@@ -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, '');
}