forked from Fediversity/fediversity.eu
allow menu entries to be subtypes of page
with an example
This commit is contained in:
parent
8397a2641d
commit
d2265cb2b7
|
@ -1,4 +1,4 @@
|
||||||
{ config, ... }:
|
{ config, lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (config) pages;
|
inherit (config) pages;
|
||||||
in
|
in
|
||||||
|
@ -10,6 +10,20 @@ in
|
||||||
menu.label = "Consortium";
|
menu.label = "Consortium";
|
||||||
menu.items = map (page: { inherit page; }) (with pages; [ nlnet oid tweag nordunet ]);
|
menu.items = map (page: { inherit page; }) (with pages; [ nlnet oid tweag nordunet ]);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
menu.label = "News";
|
||||||
|
menu.items =
|
||||||
|
let
|
||||||
|
sorted = with lib; reverseList (sortOn (entry: entry.date) config.collections.news.entry);
|
||||||
|
in
|
||||||
|
map
|
||||||
|
(page: {
|
||||||
|
page = lib.recursiveUpdate page {
|
||||||
|
title = "${page.date}: ${page.title}";
|
||||||
|
};
|
||||||
|
})
|
||||||
|
(lib.take 3 sorted);
|
||||||
|
}
|
||||||
{ page = pages.fediversity; }
|
{ page = pages.fediversity; }
|
||||||
{ page = pages.grants; }
|
{ page = pages.grants; }
|
||||||
];
|
];
|
||||||
|
|
|
@ -5,6 +5,10 @@ let
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
cfg = config;
|
cfg = config;
|
||||||
|
subtype = baseModule: types.submodule [
|
||||||
|
baseModule
|
||||||
|
{ _module.freeformType = types.attrs; }
|
||||||
|
];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
content-types.named-link = { ... }: {
|
content-types.named-link = { ... }: {
|
||||||
|
@ -36,7 +40,7 @@ in
|
||||||
description = "List of menu items";
|
description = "List of menu items";
|
||||||
type = with types; listOf (attrTag {
|
type = with types; listOf (attrTag {
|
||||||
menu = mkOption { type = submodule cfg.content-types.navigation; };
|
menu = mkOption { type = submodule cfg.content-types.navigation; };
|
||||||
page = mkOption { type = submodule cfg.content-types.page; };
|
page = mkOption { type = subtype cfg.content-types.page; };
|
||||||
link = mkOption { type = submodule cfg.content-types.named-link; };
|
link = mkOption { type = submodule cfg.content-types.named-link; };
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue