Skip to content

Commit

Permalink
Update getBuildTimeImagePath
Browse files Browse the repository at this point in the history
With changes from innerhelm, to make it work at dev time
  • Loading branch information
tylermercer committed Jan 23, 2025
1 parent 459fa8b commit 6cfddaa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/utils/getBuildTimeImagePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function initializeFilenameToDirMap() {

for (const file of rootFiles) {
const [filename] = file.split('.');
addFilenameToDirMap(filename, ""); // Root files get an empty string for the directory
addFilenameToDirMap(filename!, ""); // Root files get an empty string for the directory
}

// Process subdirectories
Expand All @@ -38,7 +38,7 @@ function initializeFilenameToDirMap() {

for (const file of files) {
const [filename] = file.split('.');
addFilenameToDirMap(filename, dir); // Subdirectory files map to their directory name
addFilenameToDirMap(filename!, dir); // Subdirectory files map to their directory name
}
}
}
Expand All @@ -47,7 +47,10 @@ function initializeFilenameToDirMap() {
initializeFilenameToDirMap();

export default function getBuildTimeImagePath({ src }: { src: string }, imageDir?: string | undefined): string {
const [filename, _, ext] = src.split('/').pop()!.split('?')[0].split('.');
const parts = src.split('/').pop()!.split('?')[0]!.split('.');

const filename = parts.at(0)!;
const ext = parts.at(-1)!;

const dir = imageDir ?? filenameToDirMap.get(filename);

Expand Down

0 comments on commit 6cfddaa

Please sign in to comment.