-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
docsGreenwood specific content like docs and guidesGreenwood specific content like docs and guidesrelease/v0.34.0
Description
Summary
In the next release, Greenwood will support dynamic routing for SSR pages and API routes, e.g.
Routing
src/
pages/
blog/
[slug].js
api/
product/
[id].js
SSR Page
export default class BlogPostPage extends HTMLElement {
#slug: string;
constructor({ params }) {
super();
this.#slug = params?.slug;
}
connectedCallback() {
this.innerHTML = `
<body>
<h1>${this.#slug}</h1>
</body>
`;
}
}API Route
export async function handler(request: Request, { params }) {
return new Response(`Product id is => ${params.id}`);
}Additional Details
Things we need to document here - https://greenwoodjs.dev/docs/pages/routing/
- Dynamic routing convention
- params
getBodyandgetLayoutsignature / type updates- Caveats include
- has to be the "last" segment in the path
getStaticPaths- Support pre-rendering (SSG) for dynamic routes greenwood#1622- dynamic directories - support dynamic directory routing capabilities for SSR pages and API routes greenwood#1623
- catch all routes - support catch all routing for dynamic SSR pages and API routes routing greenwood#1624
Greenwood Issue
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
docsGreenwood specific content like docs and guidesGreenwood specific content like docs and guidesrelease/v0.34.0
Type
Projects
Status
🔖 Ready