Its working pretty great (as seen here : Résoudre le mystère • Hugues Le Gendre) but I am having a race condition because the links.json gets computed before all the links have been rendered… And therefore is incomplete (but not so much !).
While I am waiting for this new feature (that might help me) :
I am looking for a workaround…
Any idea on how to defer the execution of this one template ? I am thinking about a sleep equivalent, maybe a very expensive loop… I wanted to do
{{- $until := (add now.Unix 2) -}}
{{- while lt now.Unix $until -}}
{{/* we just wait 2 seconds... */}}
{{- end -}}
Currently I am considering setting-up a very lightweight server running along my hugo compilation that would wait a custom delay before answering. So when I use getJSON in my template, it will wait a bit before moving on…
is useless because the Scratch is retreived before (maybe at template execution as a static object…)
or some articles templates with links are still generated after this template, but I would have thought that Hugo had a pool of goroutines for generating content, so this should not happen…
@bep, sorry to call you out, but do you have any idea of what is happening ?
Actually, I build the site twice and copy the resulting links.json to the data/ folder between builds. So there should not be any chicken-egg problem. I would very much like to avoid using an external link traversing tool is possible… but it might be the only solution…
thank you for your input.
Just to let you know: in the end, I could not make it work so I coded a script with node (I already had other scripts to manage my site) that traverses the content folder and generates the links.json file before building.