forked from Fediversity/Fediversity
split out template library
This commit is contained in:
parent
1469481829
commit
3a36a6cf29
|
@ -4,6 +4,7 @@ let
|
||||||
mkOption
|
mkOption
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
|
templates = import ./templates.nix { inherit lib; };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.templates = mkOption {
|
options.templates = mkOption {
|
||||||
|
@ -30,46 +31,25 @@ in
|
||||||
# TODO: reconsider using `page.outPath` and what to put into `locations`.
|
# TODO: reconsider using `page.outPath` and what to put into `locations`.
|
||||||
# maybe we can avoid having ".html" suffixes there.
|
# maybe we can avoid having ".html" suffixes there.
|
||||||
# since templates can output multiple files, `html` is merely one of many things we *could* produce.
|
# since templates can output multiple files, `html` is merely one of many things we *could* produce.
|
||||||
${page.outPath} = builtins.toFile "${page.name}.html" ''
|
${page.outPath} = builtins.toFile "${page.name}.html" (templates.html {
|
||||||
<html>
|
head = ''
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
||||||
|
|
||||||
<title>${page.title}</title>
|
<title>${page.title}</title>
|
||||||
<meta name="description" content="${page.description}" />
|
<meta name="description" content="${page.description}" />
|
||||||
<link rel="canonical" href="${page.outPath}" />
|
<link rel="canonical" href="${page.outPath}" />
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
${lib.indent " " (builtins.readFile (commonmark page.name page.body))}
|
|
||||||
<body>
|
|
||||||
</html>
|
|
||||||
'';
|
'';
|
||||||
|
body = builtins.readFile (commonmark page.name page.body);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
article = lib.mkDefault (config: page: {
|
article = lib.mkDefault (config: page: {
|
||||||
# TODO: create static redirects from `tail page.locations`
|
# TODO: create static redirects from `tail page.locations`
|
||||||
${page.outPath} = builtins.toFile "${page.name}.html" ''
|
${page.outPath} = builtins.toFile "${page.name}.html" (templates.html {
|
||||||
<html>
|
head = ''
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
||||||
|
|
||||||
<title>${page.title}</title>
|
<title>${page.title}</title>
|
||||||
<meta name="description" content="${page.description}" />
|
<meta name="description" content="${page.description}" />
|
||||||
${with lib;
|
<meta name="author" content="${with lib; if isList page.author then join ", " page.author else page.author}" />
|
||||||
if ! isNull page.author then
|
|
||||||
''<meta name="author" content="${if isList page.author then join ", " page.author else page.author}" />''
|
|
||||||
else ""
|
|
||||||
}
|
|
||||||
<link rel="canonical" href="${page.outPath}" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
${lib.indent " " (builtins.readFile (commonmark page.name page.body))}
|
|
||||||
<body>
|
|
||||||
</html>
|
|
||||||
'';
|
'';
|
||||||
|
body = builtins.readFile (commonmark page.name page.body);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
17
website/presentation/templates.nix
Normal file
17
website/presentation/templates.nix
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{ lib }:
|
||||||
|
{
|
||||||
|
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>
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue