diff --git a/resources/public/index.html b/resources/public/index.html deleted file mode 100644 index 2eeb826..0000000 --- a/resources/public/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - hello world d* - - - - - %%content%% - - diff --git a/src/main/example/utils.clj b/src/main/example/utils.clj index 1d5afe6..fe6c5b9 100644 --- a/src/main/example/utils.clj +++ b/src/main/example/utils.clj @@ -10,8 +10,7 @@ [starfederation.datastar.clojure.api :as d*] [starfederation.datastar.clojure.adapter.ring :refer [->sse-response on-open on-close] :as dr] [clojure.data.json :as json] - [starfederation.datastar.clojure.expressions :refer [->expr]] - )) + [starfederation.datastar.clojure.expressions :refer [->expr]])) (declare conns add-elements! sse-navigate! disconnect-sse!) @@ -22,18 +21,21 @@ ;; html utils (defn html->str [hiccup-forms] - (h/html - (hc/compile - hiccup-forms))) + (h/html (hc/compile hiccup-forms))) (defn html-template [content] - (-> (io/resource "public/index.html") - slurp - (string/split-lines) - (->> (drop 3) - (apply str)) - (str "
") - (string/replace "%%content%%" content))) + (html->str + [:html {:lang "en"} + [:head + [:title "hello world d*"] + [:script {:type "module" + :src "https://cdn.jsdelivr.net/gh/starfederation/datastar@main/bundles/datastar.js"}] + [:link {:rel "icon" + :type "image/x-icon" + :href "https://data-star.dev/cdn-cgi/image/format=auto,width=24/static/images/rocket-48x48-4c739bfaffe86a6ffcc3a6d77e3c5547730f03d74c11aa460209596d1811f7a3.png"}]] + [:body + (h/raw content) + [:div {:data-on-load (->expr (@get "/connect"))}]]])) (defn at-get [page-or-action] (format "@get('%s')" (:url page-or-action)))