diff --git a/website/presentation/default.nix b/website/presentation/default.nix index bb42a727..ca49c9a7 100644 --- a/website/presentation/default.nix +++ b/website/presentation/default.nix @@ -4,6 +4,7 @@ let mkOption types ; + templates = import ./templates.nix { inherit lib; }; in { options.templates = mkOption { @@ -30,46 +31,25 @@ 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. - ${page.outPath} = builtins.toFile "${page.name}.html" '' - - - - - - - ${page.title} - - - - - ${lib.indent " " (builtins.readFile (commonmark page.name page.body))} - - - ''; + ${page.outPath} = builtins.toFile "${page.name}.html" (templates.html { + head = '' + ${page.title} + + + ''; + body = builtins.readFile (commonmark page.name page.body); + }); }); article = lib.mkDefault (config: page: { # TODO: create static redirects from `tail page.locations` - ${page.outPath} = builtins.toFile "${page.name}.html" '' - - - - - - - ${page.title} - - ${with lib; - if ! isNull page.author then - '''' - else "" - } - - - - ${lib.indent " " (builtins.readFile (commonmark page.name page.body))} - - - ''; + ${page.outPath} = builtins.toFile "${page.name}.html" (templates.html { + head = '' + ${page.title} + + + ''; + body = builtins.readFile (commonmark page.name page.body); + }); }); }; diff --git a/website/presentation/templates.nix b/website/presentation/templates.nix new file mode 100644 index 00000000..2de9d107 --- /dev/null +++ b/website/presentation/templates.nix @@ -0,0 +1,17 @@ +{ lib }: +{ + html = { head, body }: '' + + + + + + + ${lib.indent " " head} + + + ${lib.indent " " body} + + + ''; +}