Fork me on GitHub
#biff
<
2022-09-05
>
2FO02:09:45

Good day, How can I render each game in its own div rather than the set of vectors xtdb gives me. e.g go from #{["game1"]["game2"]["game3"]} #{["game1"]["game2"]["game3"]} #{["game1"]["game2"]["game3"]} to: game1 game2 game3

(defn list-games [{:keys [biff/db] :as sys}]
  (let [games (biff/q db
                      '{:find [title]
                        :where [[_ :game/title title]]})]
    (ui/page
     {}
     (for [game games]
       [:div.text-green-600 games]))))

;; schema.clj
(def schema
  {:game/id :uuid
   :game/title :string
   :game [:map {:closed true}
          [:xt/id :game/id]
 

Jacob O'Bryant02:09:26

almost there--you can change the for bit to this:

(for [[title] games]
  [:div.text-green-600 title])
  

🙏 1
2FO20:09:05

Hello, How are new features implemented in Biff? If add the following handler to an existing feature it works fine, but I get a 404 when it's implemented as it's own feature (no console error of note). email.clj

(ns com.game.feat.email
   (:require [com.biffweb :as biff]
             [com.game.ui :as ui]))

 (defn email [_]
   (ui/page
    {}
    [:div.flex.items-center.justify-center "Email"]))

 (def features
   {:routes [["/email" {:get email}]]})

Jacob O'Bryant20:09:02

You'll need to add the new feature map to this vector in your app's main namespace: https://github.com/jacobobryant/biff/blob/master/example/src/com/example.clj#L15

🙏 1
2FO21:09:54

Thanks, as an aside how are image paths handled in Biff? if I have the following image:

/game/resources/public/img/email.jpg
What's the correct way to specify it's path? i.e
(defn email [_]
 {}
 [:div
   [:img {:src "img/email.jpg}]])

Jacob O'Bryant21:09:12

the resources/public/ directory (and also target/resources/public, for generated files) is used as a root for static files (https://github.com/jacobobryant/biff/blob/master/src/com/biffweb/impl/middleware.clj#L42 is the relevant line in Biff's internals). The path you'd use for that file is "/img/email.jpg" . i.e. add a slash at the beginning so it's an absolute path instead of relative.

🙏 1
Jacob O'Bryant20:09:26

Final draft is done: https://biffweb.com/p/updates-2022-08/ I'm also trying out using Github Discussions for blog comments: https://github.com/jacobobryant/biff/discussions/133

👍 1