This commit is contained in:
tristan 2023-12-31 09:28:28 +00:00
parent b17560cd1c
commit 5e8bb998db
3 changed files with 62 additions and 60 deletions

View file

@ -10,53 +10,55 @@
inherit system; inherit system;
}; };
nixite = import ./nixite/. {inherit pkgs;}; nixite = import ./nixite/. {inherit pkgs;};
in nixite // { in
nixite
// {
packages.${system} = {
default = nixite.mkSite (
nixite.site.applyStyle ./testing/src/style.css
(nixite.site.extractPaths {
"index.html" = with nixite.elems; (doc [
[
(title "Nixite")
]
(main [
(link "/blog" "blog")
(nixite.html.tag "img" {src = ./testing/src/favicon.png;} "")
(list [
"item 1"
"item 2"
"item 3"
])
])
]);
blog = {
"index.html" = with nixite.elems; (doc [
[
(title "A post")
]
(main [
(p ''
This is a post
'')
(link "/" "Home")
])
]);
};
})
);
packages.${system} = { serve = self.serve self.packages.${system}.default;
default = nixite.mkSite (
nixite.site.applyStyle ./testing/src/style.css
(nixite.site.extractPaths {
"index.html" = with nixite.elems; (doc [
[
(title "Nixite")
]
(main [
(link "/blog" "blog")
(nixite.html.tag "img" {src = ./testing/src/favicon.png;} "")
(list [
"item 1"
"item 2"
"item 3"
])
])
]);
blog = {
"index.html" = with nixite.elems; (doc [
[
(title "A post")
]
(main [
(p ''
This is a post
'')
(link "/" "Home")
])
]);
};
}));
serve = self.serve self.packages.${system}.default; test = let
test = import ./testing/import.nix;
test = let in
test = import ./testing/import.nix; pkgs.writeShellScriptBin "test" ''
in ${test ./testing/md.test.nix}
pkgs.writeShellScriptBin "test" '' ${test ./testing/html.test.nix}
${test ./testing/md.test.nix} ${test ./testing/elems.test.nix}
${test ./testing/html.test.nix} ${test ./testing/site.test.nix}
${test ./testing/elems.test.nix} ${test ./testing/style.test.nix}
${test ./testing/site.test.nix} '';
${test ./testing/style.test.nix} };
'';
}; };
};
} }

View file

@ -32,19 +32,20 @@ in rec {
getPaths = content: (builtins.listToAttrs (getPathsKV content)); getPaths = content: (builtins.listToAttrs (getPathsKV content));
getPathsKV = path: getPathsKV = path: (
(if builtins.isPath path if builtins.isPath path
then [ then [
{ {
name = baseNameOf path; name = baseNameOf path;
value = path; value = path;
} }
] ]
else if builtins.isAttrs path else if builtins.isAttrs path
then builtins.concatLists (map getPathsKV ( builtins.attrValues path )) then builtins.concatLists (map getPathsKV (builtins.attrValues path))
else if builtins.isList path else if builtins.isList path
then builtins.concatLists (map getPathsKV path) then builtins.concatLists (map getPathsKV path)
else []); else []
);
copyTo = prefix: site: copyTo = prefix: site:
builtins.toString ( builtins.toString (

View file

@ -103,5 +103,4 @@ in
}; };
}; };
}) })
] ]