";; Generate the hiccup for a collection of books, each book has unique details defined in each hash-map inside the collection.\n;; Destructure the keys in the hash-map for each book in turn\n\n(def practicalli-book-list\n [{:title \"Practicalli Spacemacs\"\n :url \"https://practical.li/spacemacs\"\n :image \"/practicalli-spacemacs-book-banner.png\"\n :description \"Coding Clojure with Emacs and Vim multi-modal editing\"}\n {:title \"Practicalli Clojure\"\n :url \"https://practical.li/clojure\"\n :image \"/practicalli-clojure-book-banner.png\"\n :description \"Learn the Clojure language through REPL driven development\"}])\n\n(defn books-list\n [books]\n (for [{:keys [title description url image]} books]\n [:div {:class \"column\"}\n [:a {:href url :target \"_blank\"}\n [:img {:src image}]]\n [:p [:a {:href url :target \"_blank\" }\n title]\n description]]))\n\n(book-list practicalli-book-list)\n;; => [:div {:class \"box\"} [:div {:class \"column\"} [:h2 {:class \"title has-text-centered\"} \"Freely available online books\"]] nil ([:div {:class \"column\"} [:div {:class \"columns\"} [:div {:class \"column\"} [:a {:href \"https://practical.li/spacemacs\", :target \"_blank\"} [:figure {:class \"image\"} [:img {:src \"/practicalli-spacemacs-book-banner.png\"}]]]] [:div {:class \"column\"} [:p [:a {:href \"https://practical.li/spacemacs\", :target \"_blank\", :class \"has-text-weight-bold\"} \"Practicalli Spacemacs\"] \"Emacs and Vim multi-modal editing\"]]]] [:div {:class \"column\"} [:div {:class \"columns\"} [:div {:class \"column\"} [:a {:href \"https://practical.li/clojure\", :target \"_blank\"} [:figure {:class \"image\"} [:img {:src \"/practicalli-clojure-book-banner.png\"}]]]] [:div {:class \"column\"} [:p [:a {:href \"https://practical.li/clojure\", :target \"_blank\", :class \"has-text-weight-bold\"} \"Practicalli Clojure\"] \"Learn the Clojure language through REPL driven development\"]]]])]\n"
0 commit comments