Flexible Lisp Blogware. Fork for personal use. Mirrored from https://github.com/kingcons/coleslaw originally.

twitter-summary-card.lisp 834B

1234567891011121314151617181920212223242526
  1. (defpackage :coleslaw-twitter-summary-card
  2. (:use :cl :coleslaw)
  3. (:export #:enable))
  4. (in-package :coleslaw-twitter-summary-card)
  5. (defun summary-card (post twitter-handle)
  6. "TODO: Figure if and how to include twitter:url meta property."
  7. (format nil "<meta property=\"twitter:card\" content=\"summary\" />
  8. ~@[<meta property=\"twitter:author\" content=\"~A\" />~]
  9. <meta property=\"twitter:title\" content=\"~A\" />
  10. <meta property=\"twitter:description\" content=\"~A\" />"
  11. twitter-handle
  12. (title-of post)
  13. (let ((text (content-text post)))
  14. (if (< 200 (length text))
  15. (subseq text 0 199)
  16. text))))
  17. (defun enable (&key twitter-handle)
  18. (add-injection
  19. (lambda (x)
  20. (when (typep x 'post)
  21. (summary-card x twitter-handle)))
  22. :head))