diff --git a/build.zig b/build.zig index 675167b9..e4ff0cab 100644 --- a/build.zig +++ b/build.zig @@ -92,7 +92,7 @@ pub fn build(b: *std.Build) !void { .experimental_enabled_csr = true, .copy_embedded_sources = true, .steps = .{ .serve = "serve", .dev = "dev", .@"export" = "export", .bundle = "bundle" }, - // .edge_path = b.path("site/edge.zig"), + .edge_path = b.path("site/edge.zig"), .plugins = &.{ plugins.esbuild(b, .{ .bin = b.path("site/node_modules/.bin/esbuild"), diff --git a/site/pages/examples/auth/page.zx b/site/pages/examples/auth/page.zx index e5def438..8b2a71f0 100644 --- a/site/pages/examples/auth/page.zx +++ b/site/pages/examples/auth/page.zx @@ -35,7 +35,7 @@ pub fn Page(ctx: zx.PageCtx(void, AuthState)) zx.Component { ); } -fn handleAction(ctx: zx.PageCtx(void, @import("proxy.zig").AuthState)) void { +fn handleAction(ctx: zx.PageCtx(void, AuthState)) void { if (ctx.request.method != .POST) return; const fd = ctx.request.formData(); diff --git a/site/pages/examples/server-action/page.zx b/site/pages/examples/server-action/page.zx new file mode 100644 index 00000000..aa9bc033 --- /dev/null +++ b/site/pages/examples/server-action/page.zx @@ -0,0 +1,21 @@ +pub fn Page(ctx: zx.PageContext) zx.Component { + const allocator = ctx.arena; + + return ( +
+
+ + +
+
+ ); +} + +// this should get added to server action registry maybe inside meta.zig as a list of functions, and when rendered on the client side the event handler is replaced with a stub that makes fetch call to the current page endpoint +// with autogenerated action id like we generate component id, the server than finds the actual server action and invokes it with the event data, and returns the result to the client +pub fn handleSubmit(ctx: zx.EventContext) void { + _ = ctx; +} + +const zx = @import("zx"); +const std = @import("std");