''
;
in
''
'';
diff --git a/website/structure/article.nix b/website/structure/article.nix
index 2cc82c1..ca7495d 100644
--- a/website/structure/article.nix
+++ b/website/structure/article.nix
@@ -7,7 +7,7 @@ let
cfg = config;
in
{
- content-types. article = { config, collection, ... }: {
+ content-types.article = { config, collection, ... }: {
imports = [ cfg.content-types.page ];
options = {
collection = mkOption {
@@ -27,9 +27,6 @@ in
};
};
config.name = lib.slug config.title;
- # TODO: this should be covered by the TBD `link` function instead,
- # taking a historical list of collection names into account
- config.outPath = "${collection.name}/${lib.head config.locations}";
config.outputs.html = lib.mkForce (cfg.templates.html.article cfg config);
};
}
diff --git a/website/structure/default.nix b/website/structure/default.nix
index 4150f25..6c2f541 100644
--- a/website/structure/default.nix
+++ b/website/structure/default.nix
@@ -52,13 +52,25 @@ in
type = types.str;
default = name;
};
- entry = mkOption {
- description = "An entry in the collection";
- type = types.collection (types.submodule ({
- _module.args.collection = config;
- imports = [ config.type ];
- }));
+ prefixes = mkOption {
+ description = ''
+ List of historic output locations for files in the collection
+
+ The first element is the canonical location.
+ All other elements are used to create redirects to the canonical location.
+ '';
+ type = with types; nonEmptyListOf str;
+ example = [ "." ];
};
+ entry = mkOption
+ {
+ description = "An entry in the collection";
+ type = types.collection (types.submodule ({
+ imports = [ config.type ];
+ _module.args.collection = config;
+ process-locations = ls: with lib; concatMap (l: map (p: "${p}/${l}") config.prefixes) ls;
+ }));
+ };
};
}));
};
diff --git a/website/structure/document.nix b/website/structure/document.nix
index ba02c7f..285e8ac 100644
--- a/website/structure/document.nix
+++ b/website/structure/document.nix
@@ -6,7 +6,7 @@ let
;
in
{
- content-types.document = { name, config, link, ... }: {
+ content-types.document = { name, config, options, link, ... }: {
config._module.args.link = config.link;
options = {
name = mkOption {
@@ -17,7 +17,6 @@ in
# TODO: reconsider using `page.outPath` and what to put into `locations`.
# maybe we can avoid having ".html" suffixes there.
# since templates can output multiple files, `html` is merely one of many things we *could* produce.
- # TODO: make `apply` configurable so one can programmatically modify locations
locations = mkOption {
description = ''
List of historic output locations for the resulting file
@@ -26,11 +25,17 @@ in
All other elements are used to create redirects to the canonical location.
'';
type = with types; nonEmptyListOf str;
+ apply = config.process-locations;
+ };
+ process-locations = mkOption {
+ description = "Function to post-process the output locations of contained document";
+ type = types.functionTo options.locations.type;
+ default = lib.id;
};
link = mkOption {
description = "Helper function for transparent linking to other pages";
type = with types; functionTo str;
- default = target: with lib; relativePath (head config.locations) (head target.locations);
+ default = target: with lib; relativePath config.outPath target.outPath;
};
# TODO: may not need it when using `link`; could repurpose it to render the default template
outPath = mkOption {
diff --git a/website/structure/navigation.nix b/website/structure/navigation.nix
index 17bae29..1267027 100644
--- a/website/structure/navigation.nix
+++ b/website/structure/navigation.nix
@@ -1,4 +1,4 @@
-{ config, lib, ... }:
+{ config, options, lib, ... }:
let
inherit (lib)
mkOption
@@ -7,7 +7,12 @@ let
cfg = config;
subtype = baseModule: types.submodule [
baseModule
- { _module.freeformType = types.attrs; }
+ {
+ _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;
+ }
];
in
{