Fork me on GitHub

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

Jakub Holý (HolyJak)09:12:16

if your code is online then we can have a look. Is it possible your :extend-params-fn screws up the data?


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 []
  (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}))]
    (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 ..

Jakub Holý (HolyJak)12:12:44

Do you pass the extend params fn also from your do-compile?


?? do-compile is defined in the let, all the code is above

👍 3

I don't understant

Jakub Holý (HolyJak)12:12:04

Can I git clone your blog?


lein ring server gets you to the issue

Jakub Holý (HolyJak)12:12:08

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

Jakub Holý (HolyJak)13:12:37

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")

  ;; 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")
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)]
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.

🎉 3
👀 3
Jakub Holý (HolyJak)17:12:25

Could you be so kind and 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 []
  (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}))]
    (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?

Jakub Holý (HolyJak)17:12:45

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 A PR with what?

Jakub Holý (HolyJak)17:12:23

BTW I encourage everybody to read It isn't that complicated and will give you a much better understanding.

✔️ 3