// SPDX-FileCopyrightText: © 2026 Jeffrey C. Ollie // SPDX-License-Identifier: MIT const std = @import("std"); const zine = @import("zine"); pub fn build(b: *std.Build) !void { // libghostty-vt is built by Nix from Ghostty's own source tree (see // ghostty-vt-wasm.nix) and handed over as a path. The devshell exports // both values. const vt_wasm = b.option( []const u8, "vt-wasm", "Path to ghostty-vt.wasm (the devshell exports it as $VT_WASM)", ) orelse { std.log.err("-Dvt-wasm=PATH is required; in the devshell use -Dvt-wasm=\"$VT_WASM\"", .{}); return error.MissingVtWasm; }; // Mermaid, which draws the diagrams, comes from its npm package by way of // Nix (see mermaid.nix); the devshell exports it too. const mermaid = b.option( []const u8, "mermaid", "Path to mermaid.min.js (the devshell exports it as $MERMAID_JS)", ) orelse { std.log.err("-Dmermaid=PATH is required; in the devshell use -Dmermaid=\"$MERMAID_JS\"", .{}); return error.MissingMermaid; }; const ghostty_revision = b.option( []const u8, "ghostty-revision", "The Ghostty commit the wasm was built from (the devshell exports it as $GHOSTTY_REVISION)", ) orelse "unknown"; // A module the pages import to say which Ghostty they ran against. const build_info = b.addWriteFiles().add( "build-info.js", b.fmt("export const ghosttyRevision = \"{f}\";\n", .{std.zig.fmtString(ghostty_revision)}), ); const build_assets: []const zine.BuildAsset = &.{ .{ .name = "ghostty-vt.wasm", .install_path = "ghostty-vt.wasm", .install_always = true, .lp = .{ .cwd_relative = vt_wasm }, }, .{ .name = "mermaid.min.js", .install_path = "mermaid.min.js", .install_always = true, .lp = .{ .cwd_relative = mermaid }, }, .{ .name = "build-info.js", .install_path = "build-info.js", .install_always = true, .lp = build_info, }, }; const options: zine.Options = .{ .website_root = b.path("website"), .output_path = "public", .build_assets = build_assets, }; const release = b.step("release", "Build the website into zig-out/public"); const website = zine.website(b, options); for (build_assets) |asset| website.addFileInput(asset.lp); release.dependOn(&website.step); // A Markdown copy of every page, and llms.txt indexing them, made from // the same sources. Zine refuses to write into a directory that is not // empty, so these are made apart and installed beside its output only // once it has finished. const markdown = b.addSystemCommand(&.{"node"}); markdown.addFileArg(b.path("tools/markdown.mjs")); markdown.addDirectoryArg(b.path("website")); const markdown_out = markdown.addOutputDirectoryArg("markdown"); // It reads every page's source, which the build cannot list for it. markdown.has_side_effects = true; const install_markdown = b.addInstallDirectory(.{ .source_dir = markdown_out, .install_dir = .prefix, .install_subdir = "public", }); install_markdown.step.dependOn(&website.step); release.dependOn(&install_markdown.step); const serve = b.step("serve", "Start the Zine development server"); serve.dependOn(&zine.serve(b, options).step); }