~aasg/haunted-blog

d704407c2fcb1adb1a917b6de84140f6aeb5baa4 — Aluísio Augusto Silva Gonçalves a month ago 81a5b65
haunt: Link to source commit in the site footer
2 files changed, 16 insertions(+), 2 deletions(-)

M flake.nix
M haunt.scm
M flake.nix => flake.nix +2 -1
@@ 19,13 19,14 @@

            LANG = "C.UTF-8";
            SOURCE_DATE_EPOCH = toString self.lastModified;
            GIT_COMMIT = self.rev or "";
            HAUNT_DESTDIR = placeholder "out";

            nativeBuildInputs = with final; [ haunt moreutils pandoc reuse xmlstarlet ];
            buildInputs = with final; [ guile guile-json ];
            buildPhase = ''
              runHook preBuild

              export HAUNT_DESTDIR=$out
              haunt build
              reuse spdx -o $out/files/reuse.spdx
              # Patch non-reproducible strings in the output.

M haunt.scm => haunt.scm +14 -1
@@ 42,8 42,15 @@
(define (read-asset path)
  (call-with-input-file path get-string-all))

(define (get-non-empty-envvar name)
  (let ((value (getenv name)))
    (if (or (nil? value) (string-null? value)) #f value)))

(define (output-directory)
  (or (getenv "HAUNT_DESTDIR") "site"))
  (or (get-non-empty-envvar "HAUNT_DESTDIR") "site"))

(define (site-rev)
  (get-non-empty-envvar "GIT_COMMIT"))

;----------------
;+ Markup helpers


@@ 128,6 135,12 @@
                     (li ,(profile-link "LinkedIn" "https://www.linkedin.com/in/aasg/")))))
            ,body
            (footer (p
                      ,(let ((commit (site-rev)))
                         (if (nil? commit) '()
                             `(,(output-directory)
                               " built from "
                               ,(link-as `("haunted-blog@" ,commit)
                                        (string-append "https://git.sr.ht/~aasg/haunted-blog/tree/" commit)))))
                      (span (@ (class "visually-hidden")) "Copyright:")
                      (a (@ (rel "license")
                            (href "https://creativecommons.org/licenses/by-sa/4.0/")