diff options
| author | Alexander Rolley <arolley35@gmail.com> | 2026-05-20 20:52:12 +0200 |
|---|---|---|
| committer | Alexander Rolley <arolley35@gmail.com> | 2026-05-20 20:52:12 +0200 |
| commit | 1cb3ae4156de430628abbc2ca19f51384857c6ba (patch) | |
| tree | 81c4ea45fae52eeeb64ce7af9dbda1ce0dab470f /src/frontend/Component.zig | |
| parent | d4b3a64ba6ad2862eb31e8c3081b7247c6b7b7b3 (diff) | |
| parent | 5e6b01b3b5357f43406be438074b94b3bcc90751 (diff) | |
Merge branch 'dev' of https://git.nathanreiner.xyz/memora into develop
Diffstat (limited to 'src/frontend/Component.zig')
| -rw-r--r-- | src/frontend/Component.zig | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/frontend/Component.zig b/src/frontend/Component.zig new file mode 100644 index 0000000..d90ed3b --- /dev/null +++ b/src/frontend/Component.zig @@ -0,0 +1,30 @@ +const std = @import("std"); + +const File = @import("File.zig"); + +const Self = @This(); + +name: []const u8, +parent_dir: []const u8, + +pub fn path(p: []const u8) Self { + const name = p[if (std.mem.lastIndexOfScalar( + u8, + std.mem.trim(u8, p, "/"), + '/', + )) |index| index + 1 else 0..]; + + return .{ + .name = name, + .parent_dir = p, + }; +} + +pub fn to_html_string(comptime self: Self) []const u8 { + const html: File.Html = .minify(self.parent_dir ++ "/index.html"); + const js: File.Script = .minify(self.parent_dir ++ "/index.js"); + const css: File.Style = .minify(self.parent_dir ++ "/index.css"); + return "<template id=\"--" ++ self.name ++ "\">" ++ css.to_html_string() ++ html.to_html_string() ++ js.to_html_string() ++ "</template>"; +} + +test {} |