-
-
Save brillout/a75fd8430dbc562dd10e69007121fea0 to your computer and use it in GitHub Desktop.
Nested Layout using a Route Function:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /pages/product/+route.js | |
// This Route Function is for a Nested Layout implementation. | |
// It implements a route with multiple parameters. | |
// See: | |
// - https://vike.dev/route-function | |
// - https://vike.dev/Layout | |
export { route } | |
import { resolveRoute } from 'vike/routing' | |
function route(pageContext) { | |
{ | |
const result = resolveRoute('/product/@id', pageContext.urlPathname) | |
if (result.match) { | |
result.routeParams.view = 'overview' | |
return result | |
} | |
} | |
{ | |
const result = resolveRoute('/product/@id/reviews', pageContext.urlPathname) | |
if (result.match) { | |
result.routeParams.view = 'reviews' | |
return result | |
} | |
} | |
{ | |
const result = resolveRoute('/product/@id/pricing', pageContext.urlPathname) | |
if (result.match) { | |
result.routeParams.view = 'pricing' | |
return result | |
} | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment