Commit 6d3253e
Changed files (2)
scripts
scripts/check-images.mjs
@@ -11,6 +11,7 @@ const expectedDimensions = 256
const root = path.join(path.dirname(fileURLToPath(import.meta.url)), '..')
let ok = true
+const processedBadges = new Set()
for (const { default: b } of allBadges) {
const dirname = path.basename(path.dirname(fileURLToPath(b.url)))
for (const id of b.badges) {
@@ -29,10 +30,15 @@ for (const { default: b } of allBadges) {
)
ok = false
}
+ if (processedBadges.has(id)) {
+ console.error(`Duplicate badge id: ${id} in ${dirname}`)
+ ok = false
+ }
+ processedBadges.add(id)
}
}
if (!ok) {
process.exit(1)
} else {
- console.log('All images exist and have the expected dimensions')
+ console.log('✅ All images exist, have the expected dimensions, and have unique ids.')
}
src/present-badges.ts
@@ -25,8 +25,7 @@ export const presentBadges = <P extends Presenter<List>>(
// Enhance badges with image URLs.
for (const b of newBadges) {
- const baseDir = path.basename(path.dirname(fileURLToPath(presenter.url)))
- b.image = `https://github.com/my-badges/my-badges/blob/master/badges/${baseDir}/${b.id}.png?raw=true`
+ b.image = `https://my-badges.github.io/my-badges/${b.id}.png`
}
const badgeFromPresenter = (x: Badge) => presenter.badges.includes(x.id)