8f459332fbc12cb76d5910f051483b7e80727d38 — Aluísio Augusto Silva Gonçalves 9 months ago 700e1d8
haunt: Add per-post language support
2 files changed, 15 insertions(+), 9 deletions(-)

M haunt.scm
M README.md => README.md +1 -0
@@ 23,6 23,7 @@ The following metadata is applicable to all posts:
- `author`: name or handle of the author of the post; default set in
- `author-profile`: site or profile page of the author
- `lang`: language of the post content
- `slug`: post filename; defaults to the source filename
- `tags`: list of categories the post is filed under

M haunt.scm => haunt.scm +14 -9
@@ 175,6 175,18 @@
        (cdr (reverse (fold (lambda (tag sxml)
                              (cons* (tag-link tag) ", " sxml)) '() tags))))))

(define (content-block post)
  (let* ((lang (post-ref post 'lang))
         (header-attrs (if (not lang)
                           `(@ (class "p-name"))
                           `(@ (class "p-name") (lang ,lang))))
         (body-attrs (if (not lang)
                         `(@ (id "content") (class "e-content"))
                         `(@ (id "content") (class "e-content") (lang ,lang)))))
    `((h1 ,header-attrs ,(post-ref post 'title))
      ,(when (post-ref post 'toc) (sxml-toc (post-sxml post)))
      (div ,body-attrs ,(post-sxml post)))))

(define (aasg-post-template post)
  (define %post-metadata
    `(small (@ (class "post-info"))

@@ 185,12 197,6 @@
            ,(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 (@ (id "content") (class "e-content"))
           ,(post-sxml post))))
  (define %comments-link
    `(p (@ (class "post-comments"))
        ,(link-as "View comments to this post" (post-comments-url post))

@@ 198,13 204,12 @@
        ,(link-as "send your own" (post-comments-email post))))
  `(article (@ (class "h-entry"))
            ,@(content-block post)

(define (aasg-page-template post)
  `(article (@ (class "h-entry"))
            (h1 (@ (class "p-name")) ,(post-ref post 'title))
            (div (@ (id "content") (class "e-content")) ,(post-sxml post))))
            ,@(content-block post)))

(define (taglist post)
  (define (tag-link tag)