docs: specify site-url

Fixes 404 page's relative links and styling being relative to `/`.

Cherry-picked:
- a92339d83b
- cdbda982f0
This commit is contained in:
Matt Sturgeon 2024-11-11 17:49:40 +00:00
parent 91c0602607
commit 8d29728abf
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
2 changed files with 9 additions and 0 deletions

View file

@ -5,6 +5,9 @@ multilingual = false
src = "." src = "."
title = "nixvim docs" title = "nixvim docs"
[output.html]
site-url = "@SITE_URL@"
[output.html.fold] [output.html.fold]
enable = true enable = true
level = 0 level = 0

View file

@ -6,6 +6,8 @@
nixosOptionsDoc, nixosOptionsDoc,
transformOptions, transformOptions,
hmOptions, hmOptions,
# The root directory of the site
baseHref ? "/",
}: }:
with lib; with lib;
let let
@ -238,6 +240,10 @@ let
# Using pkgs.writeShellScript helps to avoid the "bash: argument list too long" error # Using pkgs.writeShellScript helps to avoid the "bash: argument list too long" error
bash -e ${pkgs.writeShellScript "copy_docs" docs.commands} bash -e ${pkgs.writeShellScript "copy_docs" docs.commands}
# Patch book.toml
substituteInPlace ./book.toml \
--replace-fail "@SITE_URL@" "${baseHref}"
# Prepare SUMMARY.md for mdBook # Prepare SUMMARY.md for mdBook
# Using pkgs.writeText helps to avoid the same error as above # Using pkgs.writeText helps to avoid the same error as above
substituteInPlace ./SUMMARY.md \ substituteInPlace ./SUMMARY.md \