2024-11-13 15:24:41 +01:00
|
|
|
{ config, options, lib, ... }:
|
2024-11-13 15:24:41 +01:00
|
|
|
let
|
|
|
|
inherit (lib)
|
|
|
|
mkOption
|
|
|
|
types
|
|
|
|
;
|
|
|
|
cfg = config;
|
2024-11-13 15:24:41 +01:00
|
|
|
subtype = baseModule: types.submodule [
|
|
|
|
baseModule
|
2024-11-13 15:24:41 +01:00
|
|
|
{
|
|
|
|
_module.freeformType = types.attrs;
|
|
|
|
# XXX: this is supposed to be used with a finished value,
|
|
|
|
# and we don't want to process locations again.
|
|
|
|
process-locations = lib.mkForce lib.id;
|
|
|
|
}
|
2024-11-13 15:24:41 +01:00
|
|
|
];
|
2024-11-13 15:24:41 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
content-types.named-link = { ... }: {
|
|
|
|
options = {
|
|
|
|
label = mkOption {
|
|
|
|
description = "Link label";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
url = mkOption {
|
|
|
|
description = "Link URL";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-11-13 15:24:41 +01:00
|
|
|
content-types.navigation = { name, config, ... }: {
|
2024-11-13 15:24:41 +01:00
|
|
|
options = {
|
|
|
|
name = mkOption {
|
|
|
|
description = "Symbolic name, used as a human-readable identifier";
|
|
|
|
type = types.str;
|
|
|
|
default = name;
|
|
|
|
};
|
|
|
|
label = mkOption {
|
|
|
|
description = "Menu label";
|
|
|
|
type = types.str;
|
|
|
|
default = name;
|
|
|
|
};
|
|
|
|
items = mkOption {
|
|
|
|
description = "List of menu items";
|
|
|
|
type = with types; listOf (attrTag {
|
|
|
|
menu = mkOption { type = submodule cfg.content-types.navigation; };
|
2024-11-13 15:24:41 +01:00
|
|
|
page = mkOption { type = subtype cfg.content-types.page; };
|
2024-11-13 15:24:41 +01:00
|
|
|
link = mkOption { type = submodule cfg.content-types.named-link; };
|
|
|
|
});
|
|
|
|
};
|
2024-11-13 15:24:41 +01:00
|
|
|
outputs = mkOption {
|
|
|
|
description = ''
|
|
|
|
Representations of the navigation structure in different formats
|
|
|
|
|
|
|
|
It must be a function that takes the page on which the navigation is to be shown, such that relative links get computed correctly.
|
|
|
|
'';
|
|
|
|
type = with types; attrsOf (functionTo str);
|
|
|
|
default.html = cfg.templates.html.nav { menu = config; };
|
|
|
|
};
|
2024-11-13 15:24:41 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|