Files
rose-ash/events/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

36 lines
1.6 KiB
Plaintext

;; Events link-card fragment handler
;; returns: sx
;;
;; Renders event page preview card(s) by slug.
;; Supports single mode (?slug=x) and batch mode (?keys=x,y,z).
(defhandler link-card (&key slug keys)
(if keys
(let ((slugs (filter (fn (s) (not (empty? s)))
(map trim (split keys ",")))))
(<> (map (fn (s)
(let ((post (query "blog" "post-by-slug" :slug s)))
(<> (str "<!-- fragment:" s " -->")
(when post
(let ((calendars (service "calendar" "calendars-for-container"
:container-type "page"
:container-id (get post "id")))
(cal-names (join ", " (map (fn (c) (get c "name")) calendars))))
(~shared:fragments/link-card
:title (get post "title")
:image (get post "feature_image")
:subtitle cal-names
:link (app-url "events" (str "/" (get post "slug"))))))))) slugs)))
(when slug
(let ((post (query "blog" "post-by-slug" :slug slug)))
(when post
(let ((calendars (service "calendar" "calendars-for-container"
:container-type "page"
:container-id (get post "id")))
(cal-names (join ", " (map (fn (c) (get c "name")) calendars))))
(~shared:fragments/link-card
:title (get post "title")
:image (get post "feature_image")
:subtitle cal-names
:link (app-url "events" (str "/" (get post "slug"))))))))))