Skip to content

Commit

Permalink
Fixing filtering with template
Browse files Browse the repository at this point in the history
  • Loading branch information
mar1 committed Dec 29, 2024
1 parent f268ae8 commit 4f3d1e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/data/characters/TEMPLATE.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "",
"id": "unique-character-id",
"name": "",
"category": "",
"dateAdded": "",
Expand Down
12 changes: 11 additions & 1 deletion src/utils/characters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ export async function getAllCharacters(): Promise<Character[]> {
return [];
}

const characters = Object.values(characterModules) as Character[];
const characters = Object.values(characterModules)
.filter((char: any) => {
// Filter out template and invalid characters
if (!char || typeof char !== 'object') return false;
if (!char.id || char.id === '') return false;

// Get the filename from the module path
const path = Object.keys(characterModules).find(key => characterModules[key] === char) || '';
return !path.includes('TEMPLATE.json');
}) as Character[];

console.log(`Found ${characters.length} characters`);

// Sort by date added by default
Expand Down

0 comments on commit 4f3d1e4

Please sign in to comment.