# This file defines various fragments of the blog, such as the header # and footer, as functions that receive arguments to be templated into # them. # # An entire post is rendered by `renderPost`, which assembles the # fragments together in a runCommand execution. # # The post overview is rendered by 'postList'. { pkgs, lib, ... }: let inherit (builtins) filter map hasAttr replaceStrings toFile; inherit (pkgs.third_party) runCommandNoCC writeText; escape = replaceStrings [ "<" ">" "&" "'" ] [ "<" ">" "&" "'" ]; header = title: '' tazjin's blog: ${escape title}

tazjin's interblag


''; footer = ''
''; renderPost = post: runCommandNoCC "${post.key}.html" {} '' cat ${toFile "header.html" (header post.title)} > $out # Write the post title & date echo '

${escape post.title}

' >> $out echo '' >> $out # Write the actual post through cheddar's about-filter mechanism cat ${post.content} | ${pkgs.tools.cheddar}/bin/cheddar --about-filter ${post.content} >> $out echo '
' >> $out cat ${toFile "footer.html" footer} >> $out ''; # Generate a post list for all listed, non-draft posts. isDraft = post: (hasAttr "draft" post) && post.draft; isUnlisted = post: (hasAttr "listed" post) && !post.listed; includePost = post: !(isDraft post) && !(isUnlisted post); in { inherit renderPost; }