docs: simplify mdbook.nixvimOptions impl

This commit is contained in:
Matt Sturgeon 2024-10-21 19:14:42 +01:00
parent 0562e519ec
commit c693500a72
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299

View file

@ -208,7 +208,7 @@ let
nixvimOptions = mapModulesToString (
name: opts:
let
isBranch = if name == "index" then true else opts.hasComponents && opts.index.options != { };
isBranch = name == "index" || (opts.hasComponents && opts.index.options != { });
path =
if isBranch then
@ -218,9 +218,9 @@ let
else
"";
indentLevel = with builtins; length (filter isString (split "/" opts.index.path)) - 1;
indentLevel = lib.count (c: c == "/") (lib.stringToCharacters opts.index.path);
padding = lib.concatStrings (builtins.genList (_: "\t") indentLevel);
padding = lib.strings.replicate indentLevel "\t";
in
"${padding}- [${name}](${path})"
) docs.modules;