Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
tadaspetra committed Dec 6, 2024
1 parent 28de9db commit 1acff1c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/utils/votes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export interface VoteData {
[appName: string]: {
slug: string;
votes: number;
[key: string]: {
[appName: string]: {
slug: string;
votes: number;
};
};
}

Expand All @@ -12,12 +14,12 @@ export function getVotes(year?: number): VoteData {
// We import it as a module to get the data
const votes = import.meta.glob('/src/data/votes_*.json', { eager: true });
const yearFile = Object.entries(votes).find(([path]) => path.includes(`votes_${targetYear}.json`));

if (!yearFile) {
console.warn(`No votes file found for year ${targetYear}`);
return {};
}

return yearFile[1] as VoteData;
} catch (error) {
console.error('Error reading votes:', error);
Expand Down

0 comments on commit 1acff1c

Please sign in to comment.