I’m going to include a pageview counter using a simple external key-value storage. Is there a way to read
value from the API on the fly, while Hugo builds? Or right before the build. Is this possible?
Sorry, I’m looking for a way to save markdown with a new value. Will this help?
Sure.
markdown
There have been {{< num-visits >}} visits to this page.
Then in layouts/shortcodes/num-visits.html
you call the external api with resources.GetRemote
.
2 Likes
This was not too clear, so I continued to explore and found Add .RenderShortcodes · Issue #7297 · gohugoio/hugo · GitHub
Basically, this is not what I have looked for initially. Initially, I wanted a kind of PreProcessor that will get value from API and save a simple integer value in the front matter. But… this may be useful too.
If you’re going to do that, write the results to one or more json/yaml/toml files to the data directory.
Why don’t you just do this client-side?