update example to work with latest changes

This commit is contained in:
jacekpoz 2024-05-25 17:16:01 +02:00
parent 9fc59b7048
commit f6bc03bea7
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8
7 changed files with 10 additions and 11 deletions

View file

@ -8,7 +8,10 @@
inherit (lib.lists) map; inherit (lib.lists) map;
inherit (lib.strings) replaceStrings toLower; inherit (lib.strings) replaceStrings toLower;
_nte = nte {inherit extraArgs entries templates;};
extraArgs = { extraArgs = {
inherit (_nte) getEntry;
h = n: content: let h = n: content: let
id = replaceStrings [" " ";"] ["-" "-"] (toLower content); id = replaceStrings [" " ";"] ["-" "-"] (toLower content);
in /*html*/'' in /*html*/''
@ -40,7 +43,7 @@ in
buildPhase = /*sh*/'' buildPhase = /*sh*/''
runHook preBuild runHook preBuild
${nte {inherit extraArgs entries templates;}} ${_nte.buildScript}
runHook postBuild runHook postBuild
''; '';

View file

@ -1,6 +1,5 @@
_: { _: {
template = "base"; template = "base";
file = "index.html";
head = /*html*/'' head = /*html*/''
<title>nte example</title> <title>nte example</title>

View file

@ -1,13 +1,13 @@
{ {
getEntry,
pkgs, pkgs,
... ...
} @ entryArgs: let }: let
inherit (pkgs) lib; inherit (pkgs) lib;
inherit (lib.lists) map; inherit (lib.lists) map;
inherit (lib.strings) concatStrings; inherit (lib.strings) concatStrings;
in { in {
template = "base"; template = "base";
file = "posts/index.html";
head = /*html*/'' head = /*html*/''
<title>nte posts</title> <title>nte posts</title>
@ -25,7 +25,7 @@ in {
''; '';
in /*html*/'' in /*html*/''
<div id="posts"> <div id="posts">
${concatStrings (map (postFile: postItem ((import postFile) entryArgs)) ${concatStrings (map (postFile: postItem (getEntry postFile))
[ [
./test.nix ./test.nix
] ]

View file

@ -3,7 +3,6 @@
... ...
}: { }: {
template = "post"; template = "post";
file = "posts/test.html";
title = "Test post (using nte)"; title = "Test post (using nte)";
author = "jacekpoz"; author = "jacekpoz";

View file

@ -4,6 +4,7 @@
... ...
}: { }: {
name = "base"; name = "base";
format = "html";
output = /*html*/'' output = /*html*/''
<html> <html>

View file

@ -4,14 +4,11 @@
created, created,
content, content,
... ...
} @ extraArgs : let }: {
inherit (extraArgs) file;
in {
name = "post"; name = "post";
output = { output = {
template = "base"; template = "base";
inherit file;
head = /*html*/'' head = /*html*/''
<title>${title}</title> <title>${title}</title>

View file

@ -14,7 +14,7 @@
system: let system: let
pkgs = pkgsForEach.${system}; pkgs = pkgsForEach.${system};
in { in {
default = import ./engine.nix pkgs; default = import ./engine.nix pkgs ./example;
} }
); );