From c6fb7b4962778c12f786d7d4de96787459a3b4dc Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Wed, 20 May 2026 17:29:28 +0200 Subject: frontend: add comptime bundler --- src/frontend/Head.zig | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/frontend/Head.zig (limited to 'src/frontend/Head.zig') diff --git a/src/frontend/Head.zig b/src/frontend/Head.zig new file mode 100644 index 0000000..0eb090f --- /dev/null +++ b/src/frontend/Head.zig @@ -0,0 +1,58 @@ +const File = @import("File.zig"); +const Component = @import("Component.zig"); + +const z_component_code: File.Script = .minify("z-component.js"); + +pub const Meta = struct { + name: []const u8, + content: []const u8, + + pub fn to_html_string(comptime self: @This()) []const u8 { + return ""; + } +}; + +title: []const u8, +meta: []const Meta, + +pub const empty: @This() = .{ + .title = "", + .meta = &.{}, +}; + +pub fn default(comptime title: []const u8) @This() { + return .{ + .title = title, + .meta = &.{ + .{ + .name = "viewport", + .content = "width=device-width, initial-scale=1.0", + }, + }, + }; +} + +pub fn to_html_string( + comptime self: @This(), + comptime components: []const Component, + comptime styles: []const File.Style, +) []const u8 { + var content: []const u8 = "" ++ z_component_code.to_html_string(); + + content = content ++ "" ++ self.title ++ ""; + + inline for (components) |component| { + content = content ++ comptime component.to_html_string(); + } + + inline for (styles) |style| { + content = content ++ comptime style.to_html_string(); + } + + inline for (self.meta) |meta| { + content = content ++ comptime meta.to_html_string(); + } + + content = content ++ ""; + return content; +} -- cgit v1.2.3-70-g09d2