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
i think I found the issue. It was when I moved the extend-fn function in another ns
... I still have no idea ..
Do you pass the extend params fn also from your do-compile?
?? do-compile is defined in the let, all the code is above
I don't understant
Can I git clone your blog?
sure
lein ring server gets you to the issue
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?
probably yes, I took a break from tha because I was going crazy
what I want is to be able to list all posts inside articles.html
and this led me to extend-params-fn
I also have the code to generate the tags there
without my customization and using {% for post in *latest-posts* %}
in articles.html
it works, but I want ALL posts, not just the latest
I got to go, I'll get back later
Then we know where the error is :-) If you show us your customizations...
the code on the website has this problem as well. (github link above).
all the code is there, you can clone it and lein ring server
and you should be able to see it
ok, so I have something, but don't know yet what is the issue:
will post on main thread
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.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?
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?
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.
is this enough ? https://github.com/cryogen-project/cryogen-core/issues/156