Dealing with slugs inside slugs
Unanswered
Sun bear posted this in #help-forum
Sun bearOP
So im building a game site that detail page is needs to something that have a detail in detail page like this(atached a image of the structure) and im getting a error on build im a doing something wrong btw version is "next": "^13.1.6", and its not app router
22 Replies
Sun bearOP
if i remove that skin part i can get a build
@Sun bear So im building a game site that detail page is needs to something that have a detail in detail page like this(atached a image of the structure) and im getting a error on build im a doing something wrong btw version is "next": "^13.1.6", and its not app router
export const getStaticPaths: GetStaticPaths = async () => {
return {
paths: [
{
params: {
weaponId: "hello",
skinId: "world"
},
},
],
fallback: true,
}
}will get you
.../weapons/hello/skins/worldSun bearOP
i dont get it why? and do i gonna put this into the [weaponId]/index.ts ?
@joulev
@Sun bear i dont get it why? and do i gonna put this into the [weaponId]/index.ts ?
inside
[weaponId]/index.ts then just remove the skinId from the paths arrayexport const getStaticPaths: GetStaticPaths = async () => {
return {
paths: [
{
params: {
weaponId: "hello"
},
},
],
fallback: true,
}
}will get you
.../weapons/hello/skinsSun bearOP
im asking this to be sure so im gonna handle all static site building logic in the main index.ts files of those ?
example
not handle inside championId
just index?
@Sun bear im asking this to be sure so im gonna handle all static site building logic in the main index.ts files of those ?
do you need getStaticPaths? https://nextjs.org/docs/pages/building-your-application/data-fetching/get-static-paths#when-should-i-use-getstaticpaths
if you do need getStaticPaths for a route, you need to define it in that route. If you need getStaticPaths in
if you do need getStaticPaths for a route, you need to define it in that route. If you need getStaticPaths in
index.tsx and [skinId].tsx you need to have separate getStaticPaths in each fileSun bearOP
oh yes i already have it i thought for a moment you were saying something different
for example champions detail pages returns 404 somehow
export const getStaticPaths: GetStaticPaths = async ({locales}) => {
const paths = [];
for (const locale of locales as string[]) {
for (const key in champions) {
paths.push({params: {championId: key}, locale});
}
}
return {paths, fallback: true};
};export const getStaticProps: GetStaticProps = async (context) => {
const {locale} = context;
const champion = context.params?.championId;
if (!locale || !champion) {
return {
notFound: true,
revalidate: 60 * 60, // 1 hour
};
}
try {
const {data} = await ssrClient.query({
query: ChampionDetail,
variables: {championId: champion as string, language: locale},
});
if (!data.games.LoL.Champion) {
return {
notFound: true
};
}
return {
props: {championObject: data.games.LoL.Champion},
revalidate: 604800, //1 week is equal to 604800 seconds.
};
} catch {
return {
notFound: true,
revalidate: 60 * 60, // 1 hour
};
}
};@Sun bear for example champions detail pages returns 404 somehow ts
export const getStaticPaths: GetStaticPaths = async ({locales}) => {
const paths = [];
for (const locale of locales as string[]) {
for (const key in champions) {
paths.push({params: {championId: key}, locale});
}
}
return {paths, fallback: true};
};
this looks correct to me, since fallback: true it cannot return 404 just from this
before each notFound, console.log the
champion or similar and debugSun bearOP
ok let me check it its a good idea
Sun bearOP
ok found the problem for champions
deleting .next fodler fixed the issue
but weapons is still has that error
well you do similar debugging steps