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
getBody and getLayout signature / type updates
- Caveats include
Greenwood Issue
ProjectEvergreen/greenwood#882
Summary
In the next release, Greenwood will support dynamic routing for SSR pages and API routes, e.g.
Routing
SSR Page
API Route
Additional Details
Things we need to document here - https://greenwoodjs.dev/docs/pages/routing/
getBodyandgetLayoutsignature / type updatesgetStaticPaths- Support pre-rendering (SSG) for dynamic routes greenwood#1622Greenwood Issue
ProjectEvergreen/greenwood#882