]> git.frustrated-labs.net Git - frustrated-functor.dev.git/commitdiff
finish beta pipeline for processing blog posts
authorAlexander Goussas <[email protected]>
Sun, 19 Apr 2026 03:45:17 +0000 (22:45 -0500)
committerAlexander Goussas <[email protected]>
Sun, 19 Apr 2026 03:45:17 +0000 (22:45 -0500)
README.md
bin/blog-processor/src/html_formatter.zig
bin/blog-processor/src/main.zig
bin/blog-processor/src/root.zig
index.html [deleted file]
posts/06-05-2026-language-checkpoint-april.md
public/index.html [new file with mode: 0644]
public/styles.css [new file with mode: 0644]
styles.css [deleted file]
templates/index.html [new file with mode: 0644]

index 7515ba5f3ef2db1f3b7ae6c85883da6f18a99908..58352ccc5e08b5fb13983463104e5b2bae696e08 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,5 +1,10 @@
+# frustrated-functor.dev
 
+My personal blog.
 
+I write my entries in markdown files that I convert into HTML with a Zig program I built.
+
+The public assets are then deployed in a Dockerfile for ease and portability.
 
 ## Notes
 
index 99644ba8255c5718ab3bcac2fe6f30ba7515c30f..95d6be3ee25ff81877eb5ee3d9c61f72e9761abe 100644 (file)
@@ -6,11 +6,11 @@ const stdC = @cImport({
     @cInclude("stdio.h");
 });
 
-const Options = struct {
+pub const Options = struct {
     template: ?[]const u8, 
 };
 
-const HtmlFormatter = struct {
+pub const HtmlFormatter = struct {
     buffer: std.ArrayList(u8),
     opts: Options,
 
index a624fadcfdaa4a238560fd9a5bcba241b7da0b1d..d9bb7b2691e89b1a3e59cca3efe4459ed5c6f1a0 100644 (file)
@@ -1,8 +1,14 @@
 const std = @import("std");
 const blog_processor = @import("blog_processor");
 
-pub fn main() !void {
-    const alloc = std.heap.page_allocator;
-    const arena = std.heap.ArenaAllocator.init(alloc);
-    _ = arena;
+pub fn main(init: std.process.Init) !void {
+    var dirName: []const u8 = undefined;
+    var args_iter = std.process.Args.iterate(init.minimal.args);
+    _ = args_iter.next(); // Skip exec name
+    while (args_iter.next()) |arg| {
+        dirName = arg;
+        break;
+    }
+
+    try blog_processor.processBlog(init.arena.allocator(), init.io, dirName);
 }
index 49eabb0a2b7ba1b3686048960e2d073ee6858069..6978da505da4e3fab9e2c78a572561873317fad9 100644 (file)
@@ -1,7 +1,50 @@
-// const std = @import("std");
+const std = @import("std");
 
-// const md_parser = @import("./markdown_parser.zig");
-// const html = @import("./html_formatter.zig");
+const md_parser = @import("./markdown_parser.zig");
+const html = @import("./html_formatter.zig");
+
+pub fn processBlog(alloc: std.mem.Allocator, io: std.Io, dirName: []const u8) !void {
+    const dir = try std.Io.Dir.openDirAbsolute(io, dirName, .{ .iterate = true});
+    defer dir.close(io);
+
+    var iter = dir.iterate();
+    while(try iter.next(io)) |entry|  {
+        try processFile(alloc, dir, io, entry.name);
+    }
+}
+
+fn processFile(alloc: std.mem.Allocator, dir: std.Io.Dir, io: std.Io, fileName: []const u8) !void {
+    if (!std.mem.eql(u8, ".md", std.fs.path.extension(fileName))) return;
+
+    const postContents = try std.Io.Dir.readFileAlloc(dir, io, fileName, alloc, .unlimited);
+
+    var mdDoc = try md_parser.MarkdownDoc.parse(postContents, alloc);
+    defer mdDoc.deinit(alloc);
+
+    // TODO: Customize this via command line
+    const templateFile = "templates/index.html";
+    const template = try std.Io.Dir.readFileAlloc(
+        std.Io.Dir.cwd(), io, templateFile, alloc, .unlimited);
+    var formatter = html.HtmlFormatter.init(.{ .template = template });
+    defer formatter.deinit(alloc);
+
+    const htmlOut = try formatter.format(alloc, mdDoc);
+
+    // TODO: Change to file stem
+    const baseName = std.fs.path.basename(fileName);
+    const ext = ".html";
+    const newFileName = try alloc.alloc(u8, baseName.len + ext.len);
+    defer alloc.free(newFileName);
+
+    @memcpy(newFileName.ptr, baseName);
+    @memcpy(newFileName[baseName.len..].ptr, ext);
+
+    // TODO: Put them in public directory
+    try std.Io.Dir.cwd().writeFile(io, .{ 
+        .data = htmlOut,
+        .sub_path = newFileName,
+    });
+}
 
 test "all tests" {
     _ = @import("./markdown_parser.zig");
diff --git a/index.html b/index.html
deleted file mode 100644 (file)
index 9130eec..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-<!DOCTYPE html>
-<html>
-
-<head>
-  <meta charset="utf-8">
-  <title>Alexander Goussas | Programming</title>
-  <meta name="author" content="Alexander Goussas">
-  <meta name="description" content="Blog about programming">
-  <meta name="viewport" content="width=device-width, initial-scale=1">
-  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn/beer.min.css" rel="stylesheet">
-  <link href="styles.css" rel="stylesheet">
-</head>
-
-<body>
-  <h1>Alexander Goussas</h1>
-  <h2>Blog about programming and friends</h2>
-
-  <section id="posts">
-    <ul>
-      <li><a href="posts/05-05-2026-how-i-read-500-page-books-in-a-weekend.html">How I read 500 page books in a weekend</a></li>
-    </ul>
-  </section>
-  <script src="js/script.js"></script>
-</body>
-
-</html>
index 17963387f81a056730af65aa871d00667dd4a9f7..f52fe66dceb298325e6bb40ba127da9e0be49a50 100644 (file)
@@ -1,7 +1,6 @@
 ---
-title: Language Checkpoint - April
-tags: language-learning
-date: 6 April 2026
+title: Language Checkpoint April
+summary: shit
 ---
 
 This is my April 2026 language checkpoint.
diff --git a/public/index.html b/public/index.html
new file mode 100644 (file)
index 0000000..9130eec
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+  <meta charset="utf-8">
+  <title>Alexander Goussas | Programming</title>
+  <meta name="author" content="Alexander Goussas">
+  <meta name="description" content="Blog about programming">
+  <meta name="viewport" content="width=device-width, initial-scale=1">
+  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn/beer.min.css" rel="stylesheet">
+  <link href="styles.css" rel="stylesheet">
+</head>
+
+<body>
+  <h1>Alexander Goussas</h1>
+  <h2>Blog about programming and friends</h2>
+
+  <section id="posts">
+    <ul>
+      <li><a href="posts/05-05-2026-how-i-read-500-page-books-in-a-weekend.html">How I read 500 page books in a weekend</a></li>
+    </ul>
+  </section>
+  <script src="js/script.js"></script>
+</body>
+
+</html>
diff --git a/public/styles.css b/public/styles.css
new file mode 100644 (file)
index 0000000..ec02c07
--- /dev/null
@@ -0,0 +1,14 @@
+body {
+  width: 60%;
+  margin: auto;
+  margin-top: 1rem;
+  margin-bottom: 1rem;
+}
+
+h1, h2 {
+  text-align: center;
+}
+
+a {
+  text-decoration: underline;
+}
diff --git a/styles.css b/styles.css
deleted file mode 100644 (file)
index ec02c07..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-body {
-  width: 60%;
-  margin: auto;
-  margin-top: 1rem;
-  margin-bottom: 1rem;
-}
-
-h1, h2 {
-  text-align: center;
-}
-
-a {
-  text-decoration: underline;
-}
diff --git a/templates/index.html b/templates/index.html
new file mode 100644 (file)
index 0000000..22e7489
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en">
+  <meta charset="UTF-8">
+  <title>Alexander Goussas</title>
+  <meta name="viewport" content="width=device-width,initial-scale=1">
+  <link rel="stylesheet" href="styles.css">
+  <script src=""></script>
+  <body>
+    <div class="">
+      {body}
+    </div>
+  </body>
+</html>