Skip to content

Commit 0189d7a

Browse files
committed
Implemented basepath variable
References to files in the project should be able to be resolved automatically for the website change over.
1 parent 17feff2 commit 0189d7a

File tree

9 files changed

+30
-17
lines changed

9 files changed

+30
-17
lines changed

app/lib/basepath.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const BASE = process.env.NEXT_PUBLIC_BASE_PATH || '';
2+
3+
export function withBase(p: string) {
4+
return `${BASE}${p}`;
5+
}

app/skyboxes/[slug]/skybox-client.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'use client';
2+
import { withBase } from '@/app/lib/basepath';
23

34
import { useState } from 'react';
45
import Link from 'next/link';
56
import SunParams from '@/app/ui/sunparameters';
67
import FogParams from '@/app/ui/fogparameters';
78
import MapList from '@/app/ui/maplist';
89
import DownloadButton from '@/app/ui/downloadbutton';
9-
import TechnicalDetails from '@/app/ui/technical-details';
1010

1111
interface SkyboxClientProps {
1212
slug: string;
@@ -17,7 +17,7 @@ interface SkyboxClientProps {
1717
export default function SkyboxClient({ slug, skyboxData, previewCount }: SkyboxClientProps) {
1818
const [activeImage, setActiveImage] = useState(1);
1919
console.log(activeImage)
20-
const imgBase = `/Source_Skyboxes_NextJS/skyboxes/${slug}/images`;
20+
const imgBase = withBase(`/skyboxes/${slug}/images`);
2121
// Generate array of preview numbers based on previewCount
2222
const previews = Array.from({ length: previewCount }, (_, i) => i + 1);
2323

@@ -30,7 +30,7 @@ export default function SkyboxClient({ slug, skyboxData, previewCount }: SkyboxC
3030
className="inline-flex items-center text-neutral-400 hover:text-white transition-colors mb-6"
3131
>
3232
<img
33-
src="/Source_Skyboxes_NextJS/icons/back.svg"
33+
src={withBase(`/icons/back.svg`)}
3434
alt=""
3535
className="invert w-5 h-5 mr-2"
3636
/>
@@ -74,7 +74,7 @@ export default function SkyboxClient({ slug, skyboxData, previewCount }: SkyboxC
7474
</div>
7575
</div>
7676
<DownloadButton
77-
href={`/Source_Skyboxes_NextJS/skyboxes/${slug}/downloads/${slug}.7z`}
77+
href={`${withBase(`/skyboxes/${slug}/downloads/${slug}.7z`)}`}
7878
download
7979
size={skyboxData.fileSize}
8080
className="w-full md:w-auto"

app/ui/downloadbutton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use client';
2-
2+
import { withBase } from '@/app/lib/basepath';
33
import type { ComponentPropsWithoutRef } from 'react';
44

55
interface DownloadButtonProps extends ComponentPropsWithoutRef<'a'> {
@@ -43,7 +43,7 @@ export default function DownloadButton({
4343

4444
<span className="relative flex items-center gap-2">
4545
<img
46-
src="/Source_Skyboxes_NextJS/icons/download.svg"
46+
src={`${withBase(`/icons/download.svg`)}`}
4747
alt=""
4848
className="w-4 h-4 shrink-0 opacity-90 group-hover:opacity-100 transition-opacity invert brightness-0"
4949
/>

app/ui/maplist.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
type MapLink = { name: string; url: string };
2+
import { withBase } from '@/app/lib/basepath';
23

34
export default function MapList({ maps }: { maps?: MapLink[] }) {
45
if (!maps?.length)
@@ -28,7 +29,7 @@ export default function MapList({ maps }: { maps?: MapLink[] }) {
2829
<span className="text-sm text-neutral-100">{m.name}</span>
2930

3031
{/* external-link arrow */}
31-
<img src="/Source_Skyboxes_NextJS/icons/maximize.svg" alt="" className="invert w-4 h-4" />
32+
<img src={`${withBase(`/icons/maximize.svg`)}`} alt="" className="invert w-4 h-4" />
3233
</a>
3334
</li>
3435
))}

app/ui/modal.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import Meta from './meta';
44
import SunParams from './sunparameters';
55
import FogParams from './fogparameters';
66
import ViewDetailsButton from './view-details-button';
7+
import { withBase } from '@/app/lib/basepath';
78

89
// Simple chevron icon component
910
const ChevronIcon = ({ isOpen }: { isOpen: boolean }) => (
1011
<img
11-
src="/Source_Skyboxes_NextJS/icons/right-thin-chevron.svg"
12+
src={`${withBase(`/icons/right-thin-chevron.svg`)}`}
1213
alt=""
1314
className={`invert w-3 h-3 transition-transform ${isOpen ? 'rotate-90' : 'rotate-270'}`}
1415
/>
@@ -48,10 +49,10 @@ function useModalBehaviour(onClose: () => void) {
4849
export default function Modal({ slug, onClose }: { slug: string; onClose: () => void }) {
4950
const [meta, setMeta] = useState<Meta | null>(null);
5051
const [isExpanded, setIsExpanded] = useState(false);
51-
const imgBase = `/Source_Skyboxes_NextJS/skyboxes/${slug}/images`;
52+
const imgBase = `${withBase(`/skyboxes/${slug}/images`)}`;
5253

5354
useEffect(() => {
54-
fetch(`/Source_Skyboxes_NextJS/data/${slug}.json`)
55+
fetch(`${withBase(`/data/${slug}.json`)}`)
5556
.then(r => r.ok ? r.json() : null)
5657
.then(setMeta);
5758
}, [slug]);

app/ui/profile-links.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
/* app/ui/profile-links.ts */
2+
import { withBase } from '@/app/lib/basepath';
3+
24
export const profileLinks = [
35
{
46
href: 'https://github.com/Jacobdeanr',
57
label: 'GitHub',
6-
svg: '/Source_Skyboxes_NextJS/icons/github-mark-white.svg',
8+
svg: `${withBase(`/icons/github-mark-white.svg`)}`,
79
},
810
{
911
href: 'https://discord.gg/grqAfezMVs',
1012
label: 'Discord',
11-
svg: '/Source_Skyboxes_NextJS/icons/discord-symbol-white.svg',
13+
svg: `${withBase(`/icons/discord-symbol-white.svg`)}`,
1214
},
1315
{
1416
href: 'https://steamcommunity.com/id/Jakobi_OBrien',
1517
label: 'Steam',
16-
svg: '/Source_Skyboxes_NextJS/icons/steam-logo.svg',
18+
svg: `${withBase(`/icons/steam-logo.svg`)}`,
1719
},
1820
];

app/ui/skyboxcard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import Image from 'next/image';
44
import Modal from './modal';
55
import { useState } from 'react';
6+
import { withBase } from '@/app/lib/basepath';
67

78
import type { Sun } from './sunparameters';
89

@@ -19,7 +20,7 @@ interface SkyboxCardProps {
1920
export default function SkyboxCard({ slug, meta }: SkyboxCardProps) {
2021
const [open, setOpen] = useState(false);
2122
const [isHovered, setIsHovered] = useState(false);
22-
const imgBase = `/Source_Skyboxes_NextJS/skyboxes/${slug}/images`;
23+
const imgBase = withBase(`/skyboxes/${slug}/images`);
2324

2425
const displayTitle = meta?.title || slug
2526

app/ui/view-details-button.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { ComponentPropsWithoutRef } from 'react';
44
import Link from 'next/link';
5+
import { withBase } from '@/app/lib/basepath';
56

67
interface ViewDetailsButtonProps extends ComponentPropsWithoutRef<typeof Link> {
78
label?: string;
@@ -32,7 +33,7 @@ export default function ViewDetailsButton({
3233
`}
3334
>
3435
<div className="flex items-center gap-2">
35-
<img src="/Source_Skyboxes_NextJS/icons/maximize.svg" alt="" className="invert w-3 h-3 text-neutral-300 group-hover:text-white transition-colors " />
36+
<img src={`${withBase(`/icons/maximize.svg`)}`} alt="" className="invert w-3 h-3 text-neutral-300 group-hover:text-white transition-colors " />
3637
{label}
3738
</div>
3839
</Link>

next.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import type { NextConfig } from "next";
22

3+
const repoBase = process.env.NEXT_PUBLIC_BASE_PATH || '';
4+
35
const nextConfig: NextConfig = {
46
output: "export",
5-
basePath: "/Source_Skyboxes_NextJS",
6-
assetPrefix: "/Source_Skyboxes_NextJS",
7+
basePath: repoBase,
8+
assetPrefix: repoBase,
79
images: {
810
unoptimized: true,
911
},

0 commit comments

Comments
 (0)