# Assembles the website index and configures an nginx instance to # serve it. # # The website is made up of a simple header&footer and content # elements for things such as blog posts and projects. # # Content for the blog is in //web/blog instead of here. { pkgs, lib, ... }: with pkgs; with nix.yants; let inherit (builtins) readFile replaceStrings sort; inherit (third_party) writeFile runCommandNoCC; # The different types of entries on the homepage. entryClass = enum "entryClass" [ "blog" "project" "misc" ]; # The definition of a single entry. entry = struct "entry" { class = entryClass; title = string; url = string; date = int; # epoch description = option string; }; escape = replaceStrings [ "<" ">" "&" "'" ] [ "<" ">" "&" "'" ]; postToEntry = defun [ web.blog.post entry ] (post: { class = "blog"; title = "Blog: " + post.title; url = "/blog/${post.key}"; date = post.date; }); # TODO(tazjin): add date formatting function entryToDiv = defun [ entry string ] (entry: ''
${escape entry.title}
${ lib.optionalString ((entry ? description) && (entry.description != null)) "${escape entry.description}
" }