make collection entries more convenient to access

This commit is contained in:
Valentin Gagarin 2024-11-28 09:43:05 +01:00
parent 2357bfe6ad
commit 4dfcec607b
3 changed files with 8 additions and 3 deletions

View file

@ -25,7 +25,7 @@ in
default = null; default = null;
}; };
}; };
config.name = lib.slug config.title; config.name = with lib; mkDefault (slug config.title);
config.outputs.html = lib.mkForce config.outputs.html = lib.mkForce
((cfg.templates.html.page config).override (final: prev: { ((cfg.templates.html.page config).override (final: prev: {
html = { html = {

View file

@ -52,12 +52,17 @@ in
}; };
entry = mkOption { entry = mkOption {
description = "An entry in the collection"; description = "An entry in the collection";
type = types.collection (types.submodule ({ type = with types; collection (submodule ({
imports = [ config.type ]; imports = [ config.type ];
_module.args.collection = config; _module.args.collection = config;
process-locations = ls: with lib; concatMap (l: map (p: "${p}/${l}") config.prefixes) ls; process-locations = ls: with lib; concatMap (l: map (p: "${p}/${l}") config.prefixes) ls;
})); }));
}; };
by-name = mkOption {
description = "Entries accessible by symbolic name";
type = with types; attrsOf attrs;
default = with lib; listToAttrs (map (e: { name = e.name; value = e; }) config.entry);
};
}; };
})); }));
}; };

View file

@ -39,7 +39,7 @@ in
type = with types; str; type = with types; str;
}; };
}; };
config.name = lib.slug config.title; config.name = with lib; mkDefault (slug config.title);
config.summary = lib.mkDefault config.description; config.summary = lib.mkDefault config.description;
config.outputs.html = lib.mkForce config.outputs.html = lib.mkForce
((cfg.templates.html.page config).override (final: prev: { ((cfg.templates.html.page config).override (final: prev: {