generateStaticParams not working in vercel?
Unanswered
Asiatic Lion posted this in #help-forum
Asiatic LionOP
I have a list of video games that looks
export const xbox360Sheet = {
Microsoft: {
"Xbox 360": {
"0 Day Attack on Earth": {
Genre: "Shooter",
Developer: "Gulti",
Publisher: "Square Enix",
"NA Release Date": "2009-12-23T05:00:00.000Z",
"EU Release Date": "Unreleased",
"JP Release Date": "Unreleased",
"AU Release Date": "Unreleased",
"XBLA Titles": "XBLA",
"Xbox One/Series Forward Compatability": "XBO",
},
"007-Legends": {
Genre: "First-person shooter",
Developer: "Eurocom",
Publisher: "Activision",
"NA Release Date": "2012-10-16T04:00:00.000Z",
"EU Release Date": "2012-10-19T04:00:00.000Z",
"JP Release Date": "Unreleased",
"AU Release Date": "2012-10-31T04:00:00.000Z",
"XBLA Titles": null,
"Xbox One/Series Forward Compatibility": null,
},
},
},
};
While it
export const xbox360Sheet = {
Microsoft: {
"Xbox 360": {
"0 Day Attack on Earth": {
Genre: "Shooter",
Developer: "Gulti",
Publisher: "Square Enix",
"NA Release Date": "2009-12-23T05:00:00.000Z",
"EU Release Date": "Unreleased",
"JP Release Date": "Unreleased",
"AU Release Date": "Unreleased",
"XBLA Titles": "XBLA",
"Xbox One/Series Forward Compatability": "XBO",
},
"007-Legends": {
Genre: "First-person shooter",
Developer: "Eurocom",
Publisher: "Activision",
"NA Release Date": "2012-10-16T04:00:00.000Z",
"EU Release Date": "2012-10-19T04:00:00.000Z",
"JP Release Date": "Unreleased",
"AU Release Date": "2012-10-31T04:00:00.000Z",
"XBLA Titles": null,
"Xbox One/Series Forward Compatibility": null,
},
},
},
};
While it
22 Replies
Asiatic LionOP
within the page app\Games[publisher][console][gameName]\page.js
the code looks like so
the code looks like so
import React from "react";
import { xbox360Sheet } from "@/public/xbox360Sheet";
export const dynamicParams = false;
export function generateStaticParams() {
const xbox360Keys = Object.keys(xbox360Sheet);
const urlLinks = [];
for (const publisher in xbox360Sheet) {
for (const system in xbox360Sheet[publisher]) {
for (const gameName in xbox360Sheet[publisher][system]) {
const gameNameLink = gameName.replace(/ /g, "_");
console.log(gameNameLink)
urlLinks.push({
publisher,
system,
gameName:gameNameLink,
});
}
}
}
return urlLinks;
}
export default function GamesPage({ params }) {
const systemNameNoSpace = params.console;
let systemNameSpace = "";
if (systemNameNoSpace === "Xbox360") {
systemNameSpace = "Xbox 360";
}
const gameName = params.gameName.replace(/_/g, " ");
let result = xbox360Sheet[params.publisher][systemNameSpace][gameName]
return (
<div className="text-black bg-white h-full">
<div className="ml-4">
<div className="flex flex-col gap-y-8">
<GameBoxHeader
Title={gameName}
Genre={result.Genre}
Series={"NA"}
ReleaseDate={result["NA Release Date"]}
/>
<div className=" flex flex-row">
<GameBoxIcon />
<div className="my-auto ml-4">
<GameRegionSwitch />
</div>
<div className="ml-auto mr-8">
<GameContent />
</div>
</div>
</div>
<div className="mt-4">
<PND
Publisher={result.Publisher} Developer={result.Developer}
/>
</div>
<BottomInformation />
hello world {params.gameName}
</div>
</div>
);
}Looks fine in localhost
Same Url in Vercel does not work 😦
https://video-gameindex.vercel.app/Games/Microsoft/Xbox360/0_Day_Attack_on_Earth
https://video-gameindex.vercel.app/
(if you click on hello world it should take you to the same link. I was trying to make sure I wasn't just typing the URL wrong.)
https://video-gameindex.vercel.app/
(if you click on hello world it should take you to the same link. I was trying to make sure I wasn't just typing the URL wrong.)
Could you share build logs from vercel?
@Z4NR34L Could you share build logs from vercel?
Asiatic LionOP
Is there a preferred way? Like screenshot or copy and paste?
Asiatic LionOP
does it work when you run next build then next start on local?
@Ray does it work when you run next build then next start on local?
Asiatic LionOP
trying it now
The term 'next' is not recognized as the name of a cmdlet, function, script file, or operable , I'll try on cmd
well npm run build then npm run start
or yarn build / yarn start
Asiatic LionOP
okay!
@Ray well npm run build then npm run start
Asiatic LionOP
The site doesn't work
so something is wrong with my code?
which mean the problem in your generateStaticParams function
Asiatic LionOP
//@app/Games/[publisher]/[system]/[gameName]/page.js
export const dynamicParams = false;
export function generateStaticParams() {
console.log("Generating static params")
const urlLinks = [];
for (const publisher in videoGameSheet) {
for (const system in videoGameSheet[publisher]) {
for (const gameName in videoGameSheet[publisher][system]) {
const gameNameLink = gameName.replace(/ /g, "_");
console.log(gameNameLink)
urlLinks.push({
publisher,
system,
gameName:gameNameLink,
});
}
}
}
return urlLinks;
}
export default function GamesPage({ params }) {
const systemNameNoSpace = params.console;
let systemNameSpace = "";
if (systemNameNoSpace === "Xbox360") {
systemNameSpace = "Xbox 360";
}
const gameName = params.gameName.replace(/_/g, " ");
let result = videoGameSheet[params.publisher][systemNameSpace][gameName]
return (
<div className="text-black bg-white h-full">
<div className="ml-4">
<div className="flex flex-col gap-y-8">
<GameBoxHeader
Title={gameName}
Genre={result.Genre}
Series={"NA"}
ReleaseDate={result["NA Release Date"]}
/>
<div className=" flex flex-row">
<GameBoxIcon />
<div className="my-auto ml-4">
<GameRegionSwitch />
</div>
<div className="ml-auto mr-8">
<GameContent />
</div>
</div>
</div>
<div className="mt-4">
<PND
Publisher={result.Publisher} Developer={result.Developer}
/>
</div>
<BottomInformation />
hello world {params.gameName}
</div>
</div>
);
}what is videoGameSheet
Asiatic LionOP
at the moment this
export const videoGameSheet = {
Microsoft: {
"Xbox 360": {
"example": {
Genre: "Shooter",
Developer: "Gulti",
Publisher: "Square Enix",
"NA Release Date": "2009-12-23T05:00:00.000Z",
"EU Release Date": "Unreleased",
"JP Release Date": "Unreleased",
"AU Release Date": "Unreleased",
"XBLA Titles": "XBLA",
"Xbox One/Series Forward Compatability": "XBO",
},
"007-Legends": {
Genre: "First-person shooter",
Developer: "Eurocom",
Publisher: "Activision",
"NA Release Date": "2012-10-16T04:00:00.000Z",
"EU Release Date": "2012-10-19T04:00:00.000Z",
"JP Release Date": "Unreleased",
"AU Release Date": "2012-10-31T04:00:00.000Z",
"XBLA Titles": null,
"Xbox One/Series Forward Compatibility": null,
},
},
},
};I think I figured it out
ok cool