From 1f188ccf1188d1536ac0d2a017bea66d26075ae2 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Wed, 16 Oct 2024 17:32:10 +0200 Subject: insert link to #top when generated page is longer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- links/main.css | 5 +++++ src/main.zig | 16 ++++++++++++++-- 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 \\ \\Edited on {[MTIME]s} [edit] \\
- \\{[LICENSE_HOLDER]s} — + \\{[LICENSE_HOLDER]s} + \\— \\{[LICENSE_NAME]s} \\ - \\ , .{ .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( + \\[⏶] + \\ + ); + + try f.writer().writeAll( + \\ + \\ + ); } fn meta(ctx: *Context, p: []const u8) !void { -- cgit 1.4.1