From 4dfcec607ba1fa66df42f47a046d0ea4d48a2c04 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Thu, 28 Nov 2024 09:43:05 +0100 Subject: [PATCH] make collection entries more convenient to access --- website/structure/article.nix | 2 +- website/structure/collections.nix | 7 ++++++- website/structure/event.nix | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/website/structure/article.nix b/website/structure/article.nix index e443dc5..fc8986e 100644 --- a/website/structure/article.nix +++ b/website/structure/article.nix @@ -25,7 +25,7 @@ in default = null; }; }; - config.name = lib.slug config.title; + config.name = with lib; mkDefault (slug config.title); config.outputs.html = lib.mkForce ((cfg.templates.html.page config).override (final: prev: { html = { diff --git a/website/structure/collections.nix b/website/structure/collections.nix index a4f4fa6..8da3380 100644 --- a/website/structure/collections.nix +++ b/website/structure/collections.nix @@ -52,12 +52,17 @@ in }; entry = mkOption { description = "An entry in the collection"; - type = types.collection (types.submodule ({ + type = with types; collection (submodule ({ imports = [ config.type ]; _module.args.collection = config; 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); + }; }; })); }; diff --git a/website/structure/event.nix b/website/structure/event.nix index 8cfe233..595d1b5 100644 --- a/website/structure/event.nix +++ b/website/structure/event.nix @@ -39,7 +39,7 @@ in 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.outputs.html = lib.mkForce ((cfg.templates.html.page config).override (final: prev: {