From a92339d83bdc47f6d42998a5ac96020f9dd7c2d6 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 `/`. --- docs/mdbook/book.toml | 3 +++ docs/mdbook/default.nix | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/docs/mdbook/book.toml b/docs/mdbook/book.toml index 386386ac..56899e18 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 c856d5fd..3798ea5d 100644 --- a/docs/mdbook/default.nix +++ b/docs/mdbook/default.nix @@ -321,6 +321,10 @@ pkgs.stdenv.mkDerivation (finalAttrs: { cp "$file" "$path" done + # Patch book.toml + substituteInPlace ./book.toml \ + --replace-fail "@SITE_URL@" "$siteURL" + # Patch SUMMARY.md - which defiens mdBook's table of contents substituteInPlace ./SUMMARY.md \ --replace-fail "@PLATFORM_OPTIONS@" "$wrapperOptionsSummary" \ @@ -332,6 +336,10 @@ pkgs.stdenv.mkDerivation (finalAttrs: { cp -r ${search}/* $dest/search ''; + # The root directory of the site + # Can be overridden, e.g. by CI + siteURL = "/nixvim/"; + inherit (mdbook) nixvimOptionsSummary wrapperOptionsSummary