Skip to content

Commit

Permalink
Adds og meta tags for sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
MTrost committed Sep 17, 2024
1 parent 35b9cc3 commit acd4c8b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/co/gaiwan/compass/html/sessions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{:ornament/prefix "sessions-"}
(:require
[clojure.string :as str]
[co.gaiwan.compass.config :as config]
[co.gaiwan.compass.css.tokens :as t :refer :all]
[co.gaiwan.compass.db.queries :as q]
[co.gaiwan.compass.html.components :as c]
Expand Down Expand Up @@ -318,6 +319,16 @@
#_[:p (pr-str user)]
#_[:p (pr-str session)]]]))

(defn session-metas [{:session/keys [title description image]
:as session :or {description ""}}]
[:<>
[:meta {:property "og:url" :content (url-for :session/card {:id (:db/id session)})}]
[:meta {:property "og:title" :content title}]
[:meta {:property "og:description" :content (subs description 0
;; max 200 chars for twitter
(min (count description) 200))}]
[:meta {:property "og:image" :content (str (config/value :compass/origin) "/uploads/" image)}]])

(o/defstyled session-list :section#sessions
[:.sessions
:grid :gap-3
Expand Down
9 changes: 6 additions & 3 deletions src/co/gaiwan/compass/routes/sessions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@
(q/all-session-types)]}))

(defn GET-session [req]
(let [session-eid (parse-long (get-in req [:path-params :id]))]
(let [session-eid (parse-long (get-in req [:path-params :id]))
session (q/session session-eid)]
{:html/body [session-html/session-detail
(q/session session-eid)
(:identity req)]}))
session
(:identity req)]
:html/head [session-html/session-metas
session ]}))

(defn GET-session-card [req]
(let [session-eid (parse-long (get-in req [:path-params :id]))]
Expand Down

0 comments on commit acd4c8b

Please sign in to comment.