2024-11-13 15:24:41 +01:00
|
|
|
{ config, options, lib, ... }:
|
|
|
|
let
|
|
|
|
inherit (lib)
|
|
|
|
mkOption
|
|
|
|
types
|
|
|
|
;
|
|
|
|
cfg = config;
|
2024-11-13 15:24:41 +01:00
|
|
|
render-html = document:
|
|
|
|
let
|
|
|
|
eval = lib.evalModules {
|
|
|
|
class = "DOM";
|
|
|
|
modules = [ document (import ../presentation/dom.nix) ];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
toString eval.config;
|
2024-11-13 15:24:41 +01:00
|
|
|
in
|
|
|
|
{
|
2024-11-13 15:24:41 +01:00
|
|
|
content-types.article = { config, collection, ... }: {
|
2024-11-13 15:24:41 +01:00
|
|
|
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 (render-html {
|
|
|
|
html = {
|
|
|
|
head = {
|
|
|
|
title.text = config.title;
|
|
|
|
meta.description = config.description;
|
|
|
|
meta.authors = if lib.isList config.author then config.author else [ config.author ];
|
|
|
|
link.canonical = lib.head config.locations;
|
|
|
|
};
|
|
|
|
body.content = [
|
|
|
|
(cfg.menus.main.outputs.html config)
|
|
|
|
{ section.heading.content = config.title; }
|
2024-11-13 15:24:41 +01:00
|
|
|
(cfg.templates.html.markdown { inherit (config) name body; })
|
2024-11-13 15:24:41 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
});
|
2024-11-13 15:24:41 +01:00
|
|
|
};
|
|
|
|
}
|