Fork me on GitHub
#cryogen
<
2023-12-28
>
Jakub Holý (HolyJak)14:12:41

FYI: I have added the https://github.com/holyjak/blog.jakubholy.net/commit/31be1330f1ae8d103a9955e59064d0b86230a632#diff-806f65b3b5cdd4c8dde7303249f0c0a38076165c5a5d1302b7fa5529b862f3fbR50-R81 to my blog, by leveraging :extend-params-fn to compute <uri> -> related posts and using this in post-content.html to show these at the bottom of each post (the Related: under https://blog.jakubholy.net/2021/simplicity/#_summary).

Jakub Holý (HolyJak)15:12:56

On this topic, dear @yogthos: given the limitations of extensibility (`:extend-params-fn` cannot change the posts), I create the lookup uri -> other posts. A complication is that Selmer doesn’t allow me to do a lookup. What I want is st. like (when-let [related (get uri->related-posts (:uri post)) ...) but the only tools I can find is for to loop over all these entries + ifequal to get data for the current post, if any. Is there a better way to do this? 🙏 (https://github.com/holyjak/blog.jakubholy.net/commit/31be1330f1ae8d103a9955e59064d0b86230a632#diff-2774a53d881a615fd5c9dc2df1e4e67f00322922c3c3366f40990e9453da511aR26-R35)

yogthos15:12:15

I think that might be the best option at the moment, but I'd be open to add a new selmer tag, or update for to allow filtering

👍 1
seancorfield16:12:01

@U0522TWDA At work, we add the following:

(filters/add-filter! :get (fn [m k] (get m k)))
and we also rely on the @ format to dereference vars, so {{uri->related-posts|get:@post.uri}} would work.

❤️ 1
seancorfield16:12:11

(I actually had to go check the Selmer page to see if that filter was built-in because we use it so much at work @yogthos 🙂 )

yogthos16:12:51

I'm definitely open to a pr for it, seems like it would be handy for others :)

🙏 1
Jakub Holý (HolyJak)17:12:12

Nice trick, thanks a lot!

Jakub Holý (HolyJak)15:12:56

On this topic, dear @yogthos: given the limitations of extensibility (`:extend-params-fn` cannot change the posts), I create the lookup uri -> other posts. A complication is that Selmer doesn’t allow me to do a lookup. What I want is st. like (when-let [related (get uri->related-posts (:uri post)) ...) but the only tools I can find is for to loop over all these entries + ifequal to get data for the current post, if any. Is there a better way to do this? 🙏 (https://github.com/holyjak/blog.jakubholy.net/commit/31be1330f1ae8d103a9955e59064d0b86230a632#diff-2774a53d881a615fd5c9dc2df1e4e67f00322922c3c3366f40990e9453da511aR26-R35)