Skip to content

Commit

Permalink
fix incorrect star counts
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Apr 29, 2024
1 parent b508072 commit fa0f907
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib/utils/injectData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ export const injectData = (input: z.infer<typeof packagesSchema | typeof templat
for (const item of input) {
// Github
const githubIndex = Object.keys(github).find((key) =>
item.repository.toLowerCase().includes(key)
normalize(item.repository) === key
);
const githubExtra = github[githubIndex] ?? {};

// Gitlab
const gitlabIndex = Object.keys(gitlab).find((key) =>
item.repository.toLowerCase().includes(key)
normalize(item.repository) === key
);
const gitlabExtra = gitlab[gitlabIndex] ?? {};

Expand All @@ -30,3 +30,9 @@ export const injectData = (input: z.infer<typeof packagesSchema | typeof templat
}
return output;
};

function normalize(item: string) {
// want to only keep repository portion and want to strip trailing slashes
// e.g. https://github.com/microsoft/fast/tree/master/examples/svelte-starters/svelte-fast-starter
return item.toLowerCase().split('/').slice(0, 5).join('/');
}

0 comments on commit fa0f907

Please sign in to comment.