Skip to content

Commit

Permalink
Merge pull request #433 from skalenetwork/fix-number-imports
Browse files Browse the repository at this point in the history
Add fix for images with numbers in name
  • Loading branch information
dmytrotkk authored Dec 9, 2024
2 parents 708ee7e + 07fd85b commit 3df153a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion generate-imports.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const generateNamespaceExportsForDir = (dir) => {
if (svgFiles.length === 0) return; // Skip folders without SVGs

const namespaceExports = svgFiles.map(file => {
const variableName = path.basename(file, path.extname(file)).replace(/-([a-z])/g, (_, g) => g.toUpperCase()); // Convert kebab-case to camelCase
const variableName = path.basename(file, path.extname(file))
.replace(/^(_+)/, '$1')
.replace(/-([a-z0-9])/gi, (_, g) => g.toUpperCase());
return `export * as ${variableName} from './${path.basename(file)}';`;
}).join('\n');

Expand Down
4 changes: 3 additions & 1 deletion src/components/ChainLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export default function ChainLogo(props: {
if (props.app) {
logoName += `-${props.app}`
}
const baseLocalPath = logoName.replace(/-([a-z])/g, (_, g) => g.toUpperCase())
const baseLocalPath = logoName
.replace(/^(_+)/, '$1')
.replace(/-([a-z0-9])/gi, (_, g) => g.toUpperCase())

const [url, setUrl] = useState<any | null>(props.logos[baseLocalPath])

Expand Down

0 comments on commit 3df153a

Please sign in to comment.