Hello.
I’m migrating from Wordpress to static site generator, as my blog about stenography become a vector of attack on my webhost. But during several years of publishing blog-posts I had produced several hundreds of posts, which I would like to reveal to new readers - which would be impossible as they are covered with stacks of newer ones. So I have thought of generating of eg. 5 random posts that would be shown from the whole bunch for the whole publication period.
I have already groked, how to {{ range shuffle .Paginator.Pages | first 5 }}, but this makes random list only on every hugo reload, which would happen once per several weeks at best. Therefore I would like to make similar action, but on every visit on the webpage. I think, JavaScript is the only solution.
But as I’m not a programmer, I cannot write such a code by myself. Do you know of any piece of JS code, that might be useful and would fit to adjust to such task?
I use the strange-case theme which step-by-step is transformed to my needs.
Below is the piece of HTML that shows 5 random posts generated by {{ shuffle }} hugo function:
<div class="sidebar-recent hidden-xs">
<p>Random blog posts:</p>
<ul>
<li>» <a href="//localhost:1313/blog/aaa/">aaa</a></li>
<li>» <a href="//localhost:1313/blog/bbb/">bbb</a></li>
<li>» <a href="//localhost:1313/blog/ccc/">ccc</a></li>
<li>» <a href="//localhost:1313/blog/ddd/">ddd</a></li>
<li>» <a href="//localhost:1313/blog/eee/">eee</a></li>
</ul>
</div>
</div>
It looks like, I need to generate the whole list without pagination of such items:
<li>» <a href="//localhost:1313/blog/ccc/">ccc</a></li>
and then transform it by JS to list of 5 random items that would be shown at this place.
How to do it?
Thanks in advance for any help.