diff --git a/content/navigation.nix b/content/navigation.nix index 30303993..1410f617 100644 --- a/content/navigation.nix +++ b/content/navigation.nix @@ -6,6 +6,7 @@ in menus.main = { label = "Main"; items = [ + { page = pages.index // { title = "Start"; }; } { menu.label = "For you"; menu.items = map (page: { inherit page; }) diff --git a/presentation/default.nix b/presentation/default.nix index 38ca658a..9c78c0d1 100644 --- a/presentation/default.nix +++ b/presentation/default.nix @@ -5,6 +5,14 @@ let types ; templates = import ./templates.nix { inherit lib; }; + render-html = document: + let + eval = lib.evalModules { + class = "DOM"; + modules = [ document (import ./dom.nix { inherit lib; }).document ]; + }; + in + toString eval.config; in { options.templates = @@ -38,30 +46,38 @@ in in { nav = lib.mkDefault templates.nav; - page = lib.mkDefault (config: page: templates.html { - head = '' - <title>${page.title}</title> - <meta name="description" content="${page.description}" /> - <link rel="canonical" href="${lib.head page.locations}" /> - ''; - body = '' - ${config.menus.main.outputs.html page} - ${builtins.readFile (commonmark page.name page.body)} - ''; + page = lib.mkDefault (config: page: render-html { + html = { + head = { + title.text = page.title; + meta.description = page.description; + link.canonical = lib.head page.locations; + }; + body.content = '' + ${config.menus.main.outputs.html page} + + <h1>${page.title}</h1> + + ${builtins.readFile (commonmark page.name page.body)} + ''; + }; }); - article = lib.mkDefault (config: page: templates.html { - head = '' - <title>${page.title}</title> - <meta name="description" content="${page.description}" /> - ${with lib; join "\n" (map - (author: ''<meta name="author" content="${author}" />'') - (if isList page.author then page.author else [page.author])) - } - ''; - body = '' - ${config.menus.main.outputs.html page} - ${builtins.readFile (commonmark page.name page.body)} - ''; + article = lib.mkDefault (config: page: render-html { + html = { + head = { + title.text = page.title; + meta.description = page.description; + meta.authors = if lib.isList page.author then page.author else [ page.author ]; + link.canonical = lib.head page.locations; + }; + body.content = '' + ${config.menus.main.outputs.html page} + + <h1>${page.title}</h1> + + ${builtins.readFile (commonmark page.name page.body)} + ''; + }; }); }; diff --git a/presentation/templates.nix b/presentation/templates.nix index d33630b1..c0d7f652 100644 --- a/presentation/templates.nix +++ b/presentation/templates.nix @@ -1,19 +1,5 @@ { lib }: rec { - html = { head, body }: '' - <!DOCTYPE html> - <html> - <head> - <meta charset="utf-8" /> - <meta http-equiv="X-UA-Compatible" content="IE=edge" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> - ${lib.indent " " head} - </head> - <body> - ${lib.indent " " body} - <body> - </html> - ''; nav = menu: page: let render-item = item: diff --git a/structure/document.nix b/structure/document.nix index eca89c88..8af04c36 100644 --- a/structure/document.nix +++ b/structure/document.nix @@ -46,6 +46,8 @@ in default = target: with lib; "${relativePath (head config.locations) (head target.locations)}.html"; }; outputs = mkOption { + # TODO: figure out how to make this overridable at any granularity. + # it should be possible with the DOM module now. description = '' Representations of the document in different formats '';