commit aaf2e7b8e7f56c9a083e56ba054936cc683f571b
Author: tri <tri@thac.loan>
Date:   Mon Sep 29 11:04:50 2025 +0700

    include readme content in repo index

diff --git a/src/assets/style.css b/src/assets/style.css
index a7a18dc..619ef3c 100644
--- a/src/assets/style.css
+++ b/src/assets/style.css
@@ -6,11 +6,13 @@
   --table-border-color: #ddd;
   --table-row-hover-bg: papayawhip;
   --table-border-color: black;
-  --code-bg: gainsboro;
+  --pre-bg: whitesmoke;
+  --pre-border-color: gainsboro;
 }
 
 .monospace,
-code {
+code,
+pre {
   font-family: monospace;
   font-size: 1rem;
 }
@@ -27,11 +29,6 @@ h1 {
   margin: 0;
 }
 
-code {
-  background-color: var(--code-bg);
-  padding: 0 5px;
-}
-
 table {
   text-align: left;
   border-collapse: collapse;
@@ -66,6 +63,32 @@ img {
   max-height: 100%;
 }
 
+summary {
+  cursor: pointer;
+  user-select: none;
+  width: fit-content;
+}
+
+pre {
+  overflow-x: auto;
+}
+
+.readme-container {
+  margin-bottom: 1rem;
+}
+.readme-content {
+  margin: 0;
+}
+.readme-content,
+summary {
+  padding: 10px;
+  background-color: var(--pre-bg);
+  border: 1px solid var(--pre-border-color);
+}
+details:open > summary {
+  border-bottom: none;
+}
+
 @media (prefers-color-scheme: dark) {
   :root {
     background-color: #222;
@@ -76,7 +99,8 @@ img {
     --table-border-color: #444;
     --table-row-hover-bg: #444;
     --table-border-color: #ddd;
-    --code-bg: #444;
+    --pre-bg: #444;
+    --pre-border-color: #555;
   }
 
   a {
diff --git a/src/git.zig b/src/git.zig
index ae16e32..413f3f4 100644
--- a/src/git.zig
+++ b/src/git.zig
@@ -19,7 +19,6 @@ pub fn updateServerInfo(gpa: mem.Allocator, dir: fs.Dir) !void {
     });
     defer gpa.free(proc.stderr);
     defer gpa.free(proc.stdout);
-
     std.debug.assert(proc.term.Exited == 0);
 }
 
@@ -87,3 +86,17 @@ pub fn findReadme(arena: mem.Allocator, dir: fs.Dir) !?[]const u8 {
     }
     return null;
 }
+
+pub fn readFileAlloc(arena: mem.Allocator, dir: fs.Dir, file_name: []const u8) ![]const u8 {
+    var proc = try std.process.Child.run(.{
+        .allocator = arena,
+        .cwd_dir = dir,
+        .argv = &.{
+            "git",
+            "show",
+            try std.fmt.allocPrint(arena, "HEAD:{s}", .{file_name}),
+        },
+    });
+
+    return proc.stdout;
+}
diff --git a/src/main.zig b/src/main.zig
index 1f2c606..7a0ce16 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -220,11 +220,6 @@ pub fn writeRepoPage(args: RepoArgs) !void {
     );
     defer out_repo_dir.close();
 
-    if (try git.findReadme(arena, in_repo_dir)) |readme_path| {
-        println("   {s}", .{readme_path});
-        // TODO write readme content to repo index page, probably in a <details>
-    }
-
     const git_dir = try git.findGitDir(arena, in_repo_dir);
     _ = git_dir;
 
@@ -251,10 +246,43 @@ pub fn writeRepoPage(args: RepoArgs) !void {
         \\    </header>
         \\
         \\    <p>
-        \\      clone command: <code>git clone {2s}/{3s}</code><br>
+        \\      clone: <code>git clone {2s}/{3s}</code><br>
         \\      commits: <b>{1d}</b><br>
         \\    </p>
         \\
+    , .{
+        repo_name,
+        commits.len,
+        site_url,
+        if (mem.eql(u8, git_dir_path, "."))
+            repo_name
+        else
+            try std.fmt.bufPrint(&buf, "{s}/{s}", .{ repo_name, git_dir_path }),
+    });
+
+    // If there's a readme file, include it in repo index:
+    if (try git.findReadme(arena, in_repo_dir)) |readme_path| {
+        println("   {s}", .{readme_path});
+        const readme_content = try git.readFileAlloc(arena, in_repo_dir, readme_path);
+
+        try writer.interface.print(
+            \\<details class="readme-container">
+            \\  <summary>{s}</summary>
+            \\  <pre class="readme-content">
+        , .{readme_path});
+
+        try html.escape(
+            &writer.interface,
+            mem.trimEnd(u8, readme_content, "\n"),
+        );
+
+        try writer.interface.print(
+            \\  </pre>
+            \\</details>
+        , .{});
+    }
+
+    try writer.interface.print(
         \\    <div style="overflow-x:auto; padding-bottom:1rem">
         \\      <table>
         \\        <thead>
@@ -266,15 +294,7 @@ pub fn writeRepoPage(args: RepoArgs) !void {
         \\        </thead>
         \\        <tbody>
         \\
-    , .{
-        repo_name,
-        commits.len,
-        site_url,
-        if (mem.eql(u8, git_dir_path, "."))
-            repo_name
-        else
-            try std.fmt.bufPrint(&buf, "{s}/{s}", .{ repo_name, git_dir_path }),
-    });
+    , .{});
 
     var escapeBuf: [1024]u8 = undefined;
     for (commits) |cmt| {