about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--links/main.css5
-rw-r--r--src/main.zig16
2 files changed, 19 insertions, 2 deletions
diff --git a/links/main.css b/links/main.css
index 4380a12..d60270f 100644
--- a/links/main.css
+++ b/links/main.css
@@ -452,6 +452,11 @@ footer {
   clear: both;
 }
 
+body>a[href="#top"]:last-child {
+  float: right;
+  margin-top: -2rem;
+}
+
 /* Modular */
 
 a {
diff --git a/src/main.zig b/src/main.zig
index 7d33020..c40215e 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -221,10 +221,10 @@ fn build(allocator: std.mem.Allocator, f: std.fs.File, page_name: []const u8, sr
         \\<span style="">
         \\Edited on {[MTIME]s} <a href="{[SOURCE_URL]s}/{[PATH]s}">[edit]</a>
         \\</span><br/>
-        \\<b>{[LICENSE_HOLDER]s}</b> &mdash;
+        \\<b>{[LICENSE_HOLDER]s}</b>
+        \\&mdash;
         \\<a href="{[LICENSE_URL]s}" target="_blank">{[LICENSE_NAME]s}</a>
         \\</footer>
-        \\</body></html>
     , .{
         .MTIME = mtime,
         .PATH = srcpath,
@@ -233,6 +233,18 @@ fn build(allocator: std.mem.Allocator, f: std.fs.File, page_name: []const u8, sr
         .LICENSE_URL = LICENSE_URL,
         .SOURCE_URL = SOURCE_URL,
     });
+
+    const n = f.getPos() catch 0;
+    if (n > 5000)
+        try f.writer().writeAll(
+            \\<a href="#top">[&#9206;]</a>
+            \\
+        );
+
+    try f.writer().writeAll(
+        \\</body></html>
+        \\
+    );
 }
 
 fn meta(ctx: *Context, p: []const u8) !void {