forked from Fediversity/fediversity.eu
render content via structured DOM representation
This commit is contained in:
parent
01be60f9c6
commit
73c3262d74
|
@ -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; })
|
||||
|
|
|
@ -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)}
|
||||
'';
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
'';
|
||||
|
|
Reference in a new issue