feat(compiler): support sections in ssr api blocks
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -936,11 +936,16 @@ function apiBindingMap(ast: PageAst, sharedHelpers: string): Map<string, NamedDa
|
||||
if (bindings.has(block.name)) {
|
||||
throw new Error(`Duplicate .wrn api binding "${block.name}"`);
|
||||
}
|
||||
const sectioned = block.sections;
|
||||
bindings.set(block.name, {
|
||||
mode: block.mode,
|
||||
method: block.method,
|
||||
path: apiRoutePath(block.path),
|
||||
body: dataBody(block.body),
|
||||
// A sectioned block binds the payload to `data`; the legacy form keeps
|
||||
// the `with ($data)` injection, which cannot be typed.
|
||||
body: sectioned
|
||||
? `const data = $data; ${sectioned.response.trim() || "return data;"}`
|
||||
: dataBody(block.body),
|
||||
helpers: modeHelpers(ast, block.mode, sharedHelpers),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user