Skip to content

Commit

Permalink
Lots of horrible hacking to make this work as a static export with np…
Browse files Browse the repository at this point in the history
…m run build
  • Loading branch information
jmacadam committed Feb 20, 2024
1 parent 7734c19 commit 7056674
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 19 deletions.
20 changes: 18 additions & 2 deletions web/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
/* esline-env node */
/** @type {import('next').NextConfig} */
const nextConfig = {
};
let nextConfig = {};

if (process.env.NODE_ENV === 'production') {
nextConfig = {
output: 'export',
basePath: '/replay',
assetPrefix: '/replay',
env: {
NEXT_PUBLIC_BASE_PATH: '/replay',
},
};
} else {
nextConfig = {
env: {
NEXT_PUBLIC_BASE_PATH: ''
}
};
}

export default nextConfig;
9 changes: 0 additions & 9 deletions web/src/app/[sim_id]/page.tsx

This file was deleted.

9 changes: 9 additions & 0 deletions web/src/app/api/simulations/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,21 @@ function sortSteps(a: any, b: any) {
return a.step - b.step;
}

// Return a list of `params` to populate the [slug] dynamic segment
export async function generateStaticParams() {
return [{id: 'skip'}];
}

export async function GET(
request: NextRequest,
{ params }: { params: { id: string } }

) {
const id = params.id;
if (id === 'skip'){
return Response.json([]);
}

const fromIndex = Number(request.nextUrl.searchParams.get('fromIndex')) || 0;

const [totalSteps, allSteps] = await getStepsFromRedis(id, fromIndex);
Expand Down
13 changes: 6 additions & 7 deletions web/src/components/AgentSprite.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
import React from "react";
import Image from "next/image";
import styles from './Agent.module.css';

const AgentSprite: React.FC<{ agentName: string, isTalking: boolean, isThinking: boolean }> = ({ agentName, isTalking, isThinking }) => {
return (
<div className={styles.agent}>
<div>
<Image
src="/images/icons/ChatCircleDots-R.png"
<img
src={`${process.env.NEXT_PUBLIC_BASE_PATH}/images/icons/ChatCircleDots-R.png`}
alt="Talking"
className={`${styles.leftChatIcon} ${isTalking ? '' : styles.hidden}`}
width={32}
height={32}
/>
{isThinking && (
<Image
src="/images/icons/lightbulb.gif"
<img
src={`${process.env.NEXT_PUBLIC_BASE_PATH}/images/icons/lightbulb.gif` }
alt="Thinking"
className={styles.thoughtBubbleIcon}
width={16}
height={16}
/>
)}
</div>
<Image
src={`/images/characters/${agentName}.png`}
<img
src={`${process.env.NEXT_PUBLIC_BASE_PATH}/images/characters/${agentName}.png`}
alt={agentName}
width={32}
height={32}
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/RenderLevel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const RenderLevel: React.FC<{simId: string}> = ({ simId }) => {
<div className={styles.gameContainer}>

<Camera followAgent={followAgent} setFollowAgent={setFollowAgent}>
<img src="/images/maps/Large.png" alt="Default Map" />
<img src={process.env.NEXT_PUBLIC_BASE_PATH +"/images/maps/Large.png"} alt="Default Map" />
<>
{renderAgents()}
</>
Expand Down

0 comments on commit 7056674

Please sign in to comment.