I'm creating an app using the App Router pattern in Nextjs.
I have a folder structure that looks like this:
From inside the level-1
page, I would like to link to level-1/level-2
.
Obviously I can do this by hardcoding href to level-1/level-2
. However, is there a way to compute the level-1
value dynamically, so I could do something like this:
<Link href="/level-2">
This should automatically link to /level-1/level-2
</Link>
I could use usePathname - but this would work only on the client side.
Is there a way to accomplish this based only on the code structure somehow ?