Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit 34b1869

Browse files
committed
refactor: when using public folder, prefix the path with env var (#394)
Closes FRONT-533
1 parent ea8c148 commit 34b1869

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

apps/hub/src/components/dialogs/secret-dialog.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { DialogContentProps } from "@/hooks/use-dialog";
2+
import { publicUrl } from "@/lib/utils";
23
import {
34
Code,
45
DialogHeader,
@@ -19,7 +20,7 @@ export default function SecretDialogContent(props: ContentProps) {
1920
<Flex gap="4" direction="col" textAlign="center">
2021
<img
2122
className="w-20 mx-auto"
22-
src="/greg.svg"
23+
src={publicUrl("/greg.svg")}
2324
alt="Mysterious Rivet Frog"
2425
/>
2526
<Text>

apps/hub/src/components/header/header.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useAuth } from "@/domains/auth/contexts/auth";
2+
import { publicUrl } from "@/lib/utils";
23
import {
34
Button,
45
Flex,
@@ -62,7 +63,7 @@ export function Header() {
6263
>
6364
<img
6465
className="h-6"
65-
src="/icon-white-borderless.svg"
66+
src={publicUrl("/icon-white-borderless.svg")}
6667
alt="Rivet logo"
6768
/>
6869
</Link>
@@ -111,7 +112,7 @@ export function Header() {
111112
<Link to="/">
112113
<img
113114
className="h-6"
114-
src="/icon-white-borderless.svg"
115+
src={publicUrl("/icon-white-borderless.svg")}
115116
alt="Rivet logo"
116117
/>
117118
</Link>

apps/hub/src/layouts/root.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { CommandPanel } from "@/components/command-panel";
22
import { NavItem } from "@/components/header/nav-item";
3+
import { publicUrl } from "@/lib/utils";
34
import { cn } from "@rivet-gg/components";
45
import { Icon, faDiscord, faGithub, faXTwitter } from "@rivet-gg/icons";
56
import { useMatches } from "@tanstack/react-router";
@@ -43,7 +44,7 @@ const Footer = () => {
4344
<div className="flex gap-4 items-center justify-between w-full lg:w-auto lg:justify-normal">
4445
<div className="flex gap-4 items-center">
4546
<img
46-
src="/icon-white-borderless.svg"
47+
src={publicUrl("/icon-white-borderless.svg")}
4748
alt="Rivet"
4849
className="h-6"
4950
/>

apps/hub/src/lib/utils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,12 @@ export function findDuplicated<const Key extends string>(
5959

6060
return duplicatesIdx;
6161
}
62+
63+
export const publicUrl = (path: string) => {
64+
const filename = path.startsWith("/") ? path.slice(1) : path;
65+
const url = import.meta.env.BASE_URL.endsWith("/")
66+
? import.meta.env.BASE_URL
67+
: `${import.meta.env.BASE_URL}/`;
68+
69+
return `${url}${filename}`;
70+
};

0 commit comments

Comments
 (0)