This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-23
Channels
- # adventofcode (135)
- # announcements (9)
- # babashka (27)
- # beginners (97)
- # bristol-clojurians (8)
- # calva (7)
- # chlorine-clover (1)
- # cider (3)
- # clara (16)
- # clj-kondo (9)
- # cljdoc (137)
- # clojars (4)
- # clojure (110)
- # clojure-europe (118)
- # clojure-taiwan (8)
- # clojure-uk (19)
- # clojurescript (30)
- # conjure (6)
- # cryogen (32)
- # datomic (11)
- # depstar (1)
- # duct (4)
- # emacs (6)
- # fulcro (73)
- # graalvm (9)
- # keechma (7)
- # leiningen (16)
- # luminus (1)
- # malli (35)
- # meander (3)
- # off-topic (45)
- # pathom (1)
- # pedestal (2)
- # re-frame (3)
- # reagent (31)
- # reitit (2)
- # reveal (17)
- # shadow-cljs (34)
- # tools-deps (11)
- # xtdb (14)
thanks, but there is something very wrong with my build: • I get either no list of articles in the articles page • or no content in pages or posts I've spent more time on this than I would have liked to and I still have no idea why this happens
if your code is online then we can have a look. Is it possible your :extend-params-fn
screws up the data?
thanks, https://github.com/ieugen/ieugen.ro and https://www.ieugen.ro/posts/2020/week-51-2020/
I do believe it has something to do with the server/init function:
The watcher did not run with the extend-params-fn .
I've tried the bellow version but still no luck 😞 .
However lein run
should produce the proper output. I am a bit lost ...
(defn init []
(load-plugins)
(let [ignored-files (-> (resolve-config) :ignored-files)
public-dest (-> (resolve-config) :public-dest)
do-compile (fn [] (compile-assets-timed {:extend-params-fn custom/extend-params}))]
(do-compile)
(start-watcher! "content" ignored-files do-compile)
(start-watcher! "themes" ignored-files do-compile)
(println (str "Start Live Reload " public-dest))
(live-reload/start! {:paths [public-dest]
:debug? true}))
)
I'm going through commits to see what changed. commit 9a0f6998b01d583898c353cb610fc20dca45dade works ok
Do you pass the extend params fn also from your do-compile?
Can I git clone your blog?
So if you don't use your custom extend params everything works, with it something don't? Then error is in it. And what do you mean with "watched did not run the extend fn"? Did the watcher call your do-compile? Perhaps try restarting your repl?
without my customization and using {% for post in *latest-posts* %}
in articles.html
it works, but I want ALL posts, not just the latest
Then we know where the error is :-) If you show us your customizations...
all the code is there, you can clone it and lein ring server
and you should be able to see it
Can someone help me figgure out why one function call works and another does not?
(defn extend-params [params other-pages]
(let [tag-count (->> (:posts-by-tag other-pages)
(map (fn [[k v]] [k (count v)]))
(into {}))
tags-with-count (update
params :tags
#(map (fn [t] (assoc t :count (tag-count (:name t)))) %))]
(println "hellprrr")
params))
(comment
;; This does not print hellprrr
(compile-assets-timed {:extend-params-fn extend-params})
;; This does print hellp
(compile-assets-timed {:extend-params-fn (fn extend-params [params site-data]
(println "hellp")
params)})
0)
I load the plugins and call each function in the REPL.
Only the second one does it's job@holyjak: I found the source of my issues.
Adding :posts and/or :pages to the params causes havock .
After changing the names to :all-my-pages and :all-my-posts things work as expected: pages compile, I see all the posts, I see all the content.
Calling the function like (compile-assets-timed {:extend-params-fn extend-params})
also works (need to test more).
Working version:
(defn extend-params [params {:keys [pages posts] :as other-pages}]
(let [tag-count (->> (:posts-by-tag other-pages)
(map (fn [[k v]] [k (count v)]))
(into {}))
tags-with-count (update
params :tags
#(map (fn [t] (assoc t :count (tag-count (:name t)))) %))
new-site-data (assoc tags-with-count :all-my-posts posts :all-my-pages pages)]
new-site-data))
I am still puzzled as to why things behave and I do believe this is a bug that should be fixed or at least documented.
Please confirm.Could you be so kind and https://github.com/cryogen-project/cryogen-core/issues/new describing your problem, preferably in an easy to reproduce way?
and to have start-watcher!
work, it needs to call compile-assets-timed with the same options.
I changed mine to look like
(defn init []
(load-plugins)
(let [ignored-files (-> (resolve-config) :ignored-files)
public-dest (-> (resolve-config) :public-dest)
cate (fn compile-assets-timed-extend []
(compile-assets-timed {:extend-params-fn c/extend-params}))]
(cate)
(start-watcher! "content" ignored-files cate)
(start-watcher! "themes" ignored-files cate)
(println (str "Start Live Reload " public-dest))
(live-reload/start! {:paths [public-dest]
:debug? true})))
should I add a PR?Yes, you need to send the same options to the watcher as you do to other compile calls. Isn't that obvious? Here is how I do it https://github.com/holyjak/blog.jakubholy.net/blob/master/src/cryogen/server.clj#L15 A PR with what?
BTW I encourage everybody to read https://github.com/cryogen-project/cryogen-core/blob/master/src/cryogen_core/compiler.clj#L565 It isn't that complicated and will give you a much better understanding.