Files
rose-ash/blog/sx/handlers/link-card.sx
giles b0920a1121 Rename all 1,169 components to path-based names with namespace support
Component names now reflect filesystem location using / as path separator
and : as namespace separator for shared components:
  ~sx-header → ~layouts/header
  ~layout-app-body → ~shared:layout/app-body
  ~blog-admin-dashboard → ~admin/dashboard

209 files, 4,941 replacements across all services.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 22:00:12 +00:00

33 lines
1.3 KiB
Plaintext

;; Blog link-card fragment handler
;; returns: sx
;;
;; Renders link-card(s) for blog posts by slug.
;; Supports single mode (?slug=x) and batch mode (?keys=x,y,z).
(defhandler link-card (&key slug keys)
(if keys
(let ((slugs (split keys ",")))
(<> (map (fn (s)
(let ((post (query "blog" "post-by-slug" :slug (trim s))))
(when post
(<> (str "<!-- fragment:" (trim s) " -->")
(~shared:fragments/link-card
:link (app-url "blog" (str "/" (get post "slug") "/"))
:title (get post "title")
:image (get post "feature_image")
:icon "fas fa-file-alt"
:subtitle (or (get post "custom_excerpt") (get post "excerpt"))
:detail (get post "published_at_display")
:data-app "blog"))))) slugs)))
(when slug
(let ((post (query "blog" "post-by-slug" :slug slug)))
(when post
(~shared:fragments/link-card
:link (app-url "blog" (str "/" (get post "slug") "/"))
:title (get post "title")
:image (get post "feature_image")
:icon "fas fa-file-alt"
:subtitle (or (get post "custom_excerpt") (get post "excerpt"))
:detail (get post "published_at_display")
:data-app "blog"))))))