From 68cf9079c0f2d4f626b00cc8d245c47d2b055221 Mon Sep 17 00:00:00 2001 From: bc1cindy Date: Fri, 16 Oct 2026 12:10:10 -0300 Subject: [PATCH 1/2] Check the links of the built site lychee checks the HTML offline, so a link to a page or anchor the book does not hold fails the build. The site is checked under /docs/, where it is served, so a link from the root, which mdbook leaves as written, fails too. --- nix/site.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nix/site.nix b/nix/site.nix index d70b712..034649d 100644 --- a/nix/site.nix +++ b/nix/site.nix @@ -39,6 +39,13 @@ pytest -p no:cacheprovider touch $out ''; + # lychee loads CA certificates to build its HTTP client even with --offline. + links = pkgs.runCommand "links" { nativeBuildInputs = [ pkgs.lychee pkgs.cacert ]; } '' + # The site is served from /docs/, so a link from the root leaves it. + mkdir root && ln -s ${site} root/docs + lychee --offline --include-fragments --no-progress --root-dir $PWD/root root/docs + touch $out + ''; }; packages = { From a39193ac82221f765525415cd1ef757af57af2ee Mon Sep 17 00:00:00 2001 From: bc1cindy Date: Sun, 18 Oct 2026 08:18:57 -0300 Subject: [PATCH 2/2] Serve the not-found page's assets from /docs/ GitHub Pages serves the site from /docs/, but mdbook writes 404.html with , its default site-url, so the page shown for a missing path loads its stylesheets, scripts and links from the root of the domain, where none of them exist. lychee resolves relative links against the file, not its , so the link check asserts the page's itself. --- book.toml | 1 + nix/site.nix | 3 +++ 2 files changed, 4 insertions(+) diff --git a/book.toml b/book.toml index 4d6f565..0b88649 100644 --- a/book.toml +++ b/book.toml @@ -21,3 +21,4 @@ after = ["links"] [output.html] additional-css = ["theme/diagrams.css"] git-repository-url = "https://github.com/fungi-protocol/docs" +site-url = "/docs/" diff --git a/nix/site.nix b/nix/site.nix index 034649d..0490dcd 100644 --- a/nix/site.nix +++ b/nix/site.nix @@ -43,6 +43,9 @@ links = pkgs.runCommand "links" { nativeBuildInputs = [ pkgs.lychee pkgs.cacert ]; } '' # The site is served from /docs/, so a link from the root leaves it. mkdir root && ln -s ${site} root/docs + # The 404 page needs for browsers to find its assets. + # Lychee does not check this, so verify it separately. + grep -qF '' root/docs/404.html lychee --offline --include-fragments --no-progress --root-dir $PWD/root root/docs touch $out '';