~aasg/haunted-blog

f2bedc9aa4883deabedb5112d729138a28dc2b4e — Aluísio Augusto Silva Gonçalves 1 year, 2 months ago 2d7c9c9
Render post tags in post metadata
2 files changed, 47 insertions(+), 14 deletions(-)

M haunt.scm
M static/css/site.css
M haunt.scm => haunt.scm +31 -14
@@ 160,22 160,39 @@
  (string-append "mailto:aasg/public-inbox@lists.sr.ht?subject="
                 (uri-encode (string-append "Re: " (post-ref post 'title)))))

(define (filed-under post)
  (define (tag-link tag)
    `(span (@ (class "p-category")) ,tag))
  (let ((tags (post-ref post 'tags)))
    (if (or (not tags) (null? tags)) #f
        (cdr (reverse (fold (lambda (tag sxml)
                              (cons* (tag-link tag) ", " sxml)) '() tags))))))

(define (aasg-post-template post)
  (define %post-metadata
    `(small (@ (class "post-info"))
            "Published on "
            (time (@ (class "dt-published")) ,(date->string (post-date post) "~1"))
            " by "
            ,(author-hcard post)
            ,(prefix-sxml " in reply to " (cite-if-reply post))
            ,(prefix-sxml ". Filed under " (filed-under post))
            "."))
  (define %post-contents
    `((h1 (@ (class "p-name"))
          ,(post-ref post 'title))
      ,(when (post-ref post 'toc) (sxml-toc (post-sxml post)))
      (div (@ (class "e-content"))
           ,(post-sxml post))))
  (define %comments-link
    `(p (@ (class "post-comments"))
        ,(link-as "View comments to this post" (post-comments-url post))
        " or "
        ,(link-as "send your own" (post-comments-email post))))
  `(article (@ (class "h-entry"))
            (small (@ (class "post-info"))
              "Published on "
              (time (@ (class "dt-published")) ,(date->string (post-date post) "~1"))
              " by "
              ,(author-hcard post)
              ,(prefix-sxml " in reply to " (cite-if-reply post)))
            (h1 (@ (class "p-name")) ,(post-ref post 'title))
            ,(when (post-ref post 'toc) (sxml-toc (post-sxml post)))
            (div (@ (class "e-content"))
                 ,(post-sxml post))
            (p (@ (class "post-comments"))
              ,(link-as "View comments to this post" (post-comments-url post))
              " or "
              ,(link-as "send your own" (post-comments-email post)))))
            ,%post-metadata
            ,@%post-contents
            ,%comments-link))

(define (aasg-page-template post)
  `(article (@ (class "h-entry"))

M static/css/site.css => static/css/site.css +16 -0
@@ 130,8 130,24 @@ h1, h2, h3, h4, h5, h6 {
  padding-top: 4rem;
}

/* Except the article title from the above rule.  In fact, apply no
 * padding at all. */
.h-entry h1.p-name {
  margin: 0;
  padding: 0;
}

/* Hide identities from the homepage; those are public, but for machine
 * processing only. */
article.h-card #identities {
  display: none;
}

/* Style tags. */
.h-entry .p-category {
  font-family: monospace;
  font-variant: small-caps;
}
.h-entry .p-category:before {
  content: "#";
}