forked from Fediversity/fediversity.eu
extract generic document type
This commit is contained in:
parent
7eb147a5a0
commit
24bd786896
|
@ -14,18 +14,14 @@ in
|
|||
};
|
||||
};
|
||||
config.content-types = {
|
||||
page = { name, config, ... }: {
|
||||
document = { name, config, ... }: {
|
||||
options = {
|
||||
|
||||
name = mkOption {
|
||||
description = "Symbolic name, used as a human-readable identifier";
|
||||
type = types.str;
|
||||
default = name;
|
||||
};
|
||||
title = mkOption {
|
||||
description = "Page title";
|
||||
type = types.str;
|
||||
default = name;
|
||||
};
|
||||
locations = mkOption {
|
||||
description = ''
|
||||
List of historic output locations for the resulting file
|
||||
|
@ -40,6 +36,7 @@ in
|
|||
type = with types; functionTo str;
|
||||
default = target: "TODO: compute the relative path based on `locations`";
|
||||
};
|
||||
# TODO: may not need it when using `link`; could repurpose it to render the default template
|
||||
outPath = mkOption {
|
||||
description = ''
|
||||
Location of the page, used for transparently creating links
|
||||
|
@ -47,6 +44,28 @@ in
|
|||
type = types.str;
|
||||
default = lib.head config.locations;
|
||||
};
|
||||
# TODO: maybe it would even make sense to split routing and rendering altogether.
|
||||
# in that case, templates would return strings, and a different
|
||||
# piece of the machinery resolves rendering templates to files
|
||||
# using `locations`.
|
||||
# then we'd have e.g. `templates.html` and `templates.atom` for
|
||||
# different output formats.
|
||||
template = mkOption {
|
||||
description = ''
|
||||
Function that converts the page contents to files
|
||||
'';
|
||||
type = with types; functionTo (functionTo options.files.type);
|
||||
};
|
||||
};
|
||||
};
|
||||
page = { name, config, ... }: {
|
||||
imports = [ cfg.content-types.document ];
|
||||
options = {
|
||||
title = mkOption {
|
||||
description = "Page title";
|
||||
type = types.str;
|
||||
default = name;
|
||||
};
|
||||
description = mkOption {
|
||||
description = ''
|
||||
One-sentence description of page contents
|
||||
|
@ -65,14 +84,8 @@ in
|
|||
'';
|
||||
type = types.str;
|
||||
};
|
||||
template = mkOption {
|
||||
description = ''
|
||||
Function that converts the page contents to files
|
||||
'';
|
||||
type = with types; functionTo (functionTo options.files.type);
|
||||
default = cfg.templates.page;
|
||||
};
|
||||
};
|
||||
config.template = cfg.templates.page;
|
||||
};
|
||||
|
||||
article = { config, collectionName, ... }: {
|
||||
|
@ -91,7 +104,7 @@ in
|
|||
};
|
||||
config.name = lib.slug config.title;
|
||||
config.outPath = "${collectionName}/${lib.head config.locations}";
|
||||
config.template = cfg.templates.article;
|
||||
config.template = lib.mkForce cfg.templates.article;
|
||||
};
|
||||
|
||||
named-link = { ... }: {
|
||||
|
|
Reference in a new issue