Skip to content

Commit

Permalink
fix: add base url to image paths
Browse files Browse the repository at this point in the history
  • Loading branch information
yosevu committed Nov 5, 2022
1 parent 8f46062 commit 6a81ec0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/locations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type LegacyReview = {
placeId: number;
};

const BASE_URL = import.meta.env['BASE_URL'];

function getReviewImageURL(
imagePath: string,
imageID: string,
Expand All @@ -55,7 +57,7 @@ function getReviewImageURL(
const imageName = legacyImages.find(
(image) => image.id.toString() === imageID
)?.fd;
return imageName ? `${imagePath}${imageName}` : null;
return imageName ? `${BASE_URL}${imagePath}${imageName}` : null;
}

function getLocationImageURL(
Expand All @@ -67,8 +69,8 @@ function getLocationImageURL(
(image) => image.id.toString() === imageID
)?.fd;
return imageName
? `${imagePath}${imageName}`
: 'img/location-card-header_bg.png';
? `${BASE_URL}${imagePath}${imageName}`
: `${BASE_URL}img/location-card-header_bg.png`;
}

function getImageDescription(imageDescription: string) {
Expand All @@ -92,7 +94,7 @@ function transformReview({
id,
reviewerName,
text,
imageURL: getReviewImageURL('/img/reviews/', imageID, legacyReviewImages),
imageURL: getReviewImageURL('img/reviews/', imageID, legacyReviewImages),
imageDescription: getImageDescription(reviewImageAlt),
starRating,
placeID,
Expand Down Expand Up @@ -146,7 +148,7 @@ function transformLocations(legacyPlaces: LegacyPlace[]): Locations {
url,
locationURL: getLocationURL(id),
imageURL: getLocationImageURL(
'/img/locations/',
'img/locations/',
imageID,
legacyPlaceImages
),
Expand Down

0 comments on commit 6a81ec0

Please sign in to comment.