const markdownToHtml = @import("md_to_html.zig").markdownToHtml;
+const writings_nav_buttons_paths = .{
+ .{ "writings/books/le-monde-de-ponpon/chapter-1", null, "/writings/books/le-monde-de-ponpon/chapter-2" },
+ .{ "writings/books/le-monde-de-ponpon/chapter-2", "/writings/books/le-monde-de-ponpon/chapter-1", "/writings/books/le-monde-de-ponpon/chapter-3" },
+ .{ "writings/books/le-monde-de-ponpon/chapter-3", "/writings/books/le-monde-de-ponpon/chapter-2", null },
+};
+
+fn writingNavButtonPath(comptime kind: enum { prev, next }, path: []const u8) ?[]const u8 {
+ inline for (writings_nav_buttons_paths) |nav_buttons_paths| {
+ if (std.mem.eql(u8, nav_buttons_paths[0], path)) {
+ switch (kind) {
+ .prev => return nav_buttons_paths[1],
+ .next => return nav_buttons_paths[2],
+ }
+ }
+ }
+
+ return null;
+}
+
fn parentDirPath(path: []const u8) ?[]const u8 {
for (0..path.len) |idx| {
const i = path.len - idx - 1;
try markdownToHtml(temp_buffer_writer.any(), md_file_reader.any());
+ try temp_buffer_writer.writeAll("<div id=\"writings-nav\">");
+
+ if (writingNavButtonPath(.prev, route)) |path| {
+ try temp_buffer_writer.print("<a href=\"{s}\">Previous</a>", .{path});
+ }
+
+ if (writingNavButtonPath(.next, route)) |path| {
+ try temp_buffer_writer.print("<a href=\"{s}\">Next</a>", .{path});
+ }
+
+ try temp_buffer_writer.writeAll("</div>");
+
break :no_index_file;
}
}