Function from utils.jl does not update
blackTay opened this issue · 2 comments
I follow the description on https://franklinjl.org/syntax/utils/ to create a hfun
function. The example gives the hfun_recentblogposts()
function which lists the (dates of) the three most recent .md files in a folder. This works well, as long as the files do not change. Upon e.g. deleting a file, that file is still listed after refreshing the page; only restarting the server removes the file from the list. Is this caused due to caching? Is there a way to execute the function every time the page gets refreshed?
(As you can guess, I am new to fanklin.jl; I also looked into the "inserting code" section of the documentation, but that seems to be rather for writing tutorials where the code is also displayed.)
Many thanks in advance!
Let's say you have index.md
which has the {{recentblogposts}}
. Franklin will only reevaluate that function if index.md
changes. So in your case what you can try is to just re-save index.md
(without real change) and check that the list gets updated.
Refreshing the page from the browser does not signal anything to Franklin (I imagine it would be possible but it's not there now and unlikely to be added soon). Franklin only looks at changes in the source files and reacts to that. So it's not really caching, it's just not reacting to the file being deleted.
Note: when you deploy, everything will be evaluated from scratch and so, in particular, you won't have the issue of ghost files in the list at deployment time.
Thank you, also for the clarification that refreshing the page from the client side does not signal anything to Franklin. It would be a great feature though, to be able to run some code every time someone accesses a page, in order to display some live information served from a back-end -- but I guess that this is, at least at the moment, beyond the intended purpose of Franklin.