Fediversity/website/structure/article.nix

55 lines
1.6 KiB
Nix
Raw Normal View History

{ config, options, lib, ... }:
let
inherit (lib)
mkOption
types
;
cfg = config;
in
{
content-types.article = { config, collection, ... }: {
imports = [ cfg.content-types.page ];
options = {
collection = mkOption {
description = "Collection this article belongs to";
type = options.collections.type.nestedTypes.elemType;
default = collection;
};
date = mkOption {
description = "Publication date";
type = with types; str;
default = null;
};
author = mkOption {
description = "Page author";
type = with types; either str (nonEmptyListOf str);
default = null;
};
};
config.name = lib.slug config.title;
2024-11-13 15:24:41 +01:00
config.outputs.html = lib.mkForce ((cfg.templates.html.page config).override {
html = {
2024-11-13 15:24:41 +01:00
# TODO: make authors always a list
head.meta.authors = if lib.isList config.author then config.author else [ config.author ];
body.content = lib.mkForce [
(cfg.menus.main.outputs.html config)
2024-11-13 15:24:41 +01:00
{
section = {
heading = {
# TODO: i18n support
# TODO: structured dates
before = [{ p.content = "Published ${config.date}"; }];
content = config.title;
after = [{ p.content = "Written by ${config.author}"; }];
};
content = [
(cfg.templates.html.markdown { inherit (config) name body; })
];
2024-11-13 15:24:41 +01:00
};
}
];
};
});
};
}