From 8d29728abfcc2e4207afb3fd8606feff17c15cec Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Mon, 11 Nov 2024 17:49:40 +0000 Subject: [PATCH] docs: specify `site-url` Fixes 404 page's relative links and styling being relative to `/`. Cherry-picked: - a92339d83bdc47f6d42998a5ac96020f9dd7c2d6 - cdbda982f04bd021cfa8d549896410c5caf84fdf --- docs/mdbook/book.toml | 3 +++ docs/mdbook/default.nix | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/docs/mdbook/book.toml b/docs/mdbook/book.toml index 59e8c630..4024b309 100644 --- a/docs/mdbook/book.toml +++ b/docs/mdbook/book.toml @@ -5,6 +5,9 @@ multilingual = false src = "." title = "nixvim docs" +[output.html] +site-url = "@SITE_URL@" + [output.html.fold] enable = true level = 0 diff --git a/docs/mdbook/default.nix b/docs/mdbook/default.nix index 1e8d8821..28d70b91 100644 --- a/docs/mdbook/default.nix +++ b/docs/mdbook/default.nix @@ -6,6 +6,8 @@ nixosOptionsDoc, transformOptions, hmOptions, + # The root directory of the site + baseHref ? "/", }: with lib; let @@ -238,6 +240,10 @@ let # Using pkgs.writeShellScript helps to avoid the "bash: argument list too long" error bash -e ${pkgs.writeShellScript "copy_docs" docs.commands} + # Patch book.toml + substituteInPlace ./book.toml \ + --replace-fail "@SITE_URL@" "${baseHref}" + # Prepare SUMMARY.md for mdBook # Using pkgs.writeText helps to avoid the same error as above substituteInPlace ./SUMMARY.md \