@
alexkuang 太对了.
刚才问了下 ChatGPT, 他也是这么说的. 哈哈....
我不知道在这儿怎么贴代码, ChatGPT 有些例程的
Yes, it is possible to use JavaScript to display a random post on the homepage of your Hugo + Cloudflare + GitHub blog site. Here is an example of how you can do this:
First, you will need to create a list of all the posts that you want to be included in the random selection. You can do this by querying the Hugo API for a list of all your posts and storing the results in a JavaScript array.
Next, you will need to write a function that selects a random post from the array of posts. This can be done using the Math.random() function to generate a random number, and then using this number to select a random post from the array.
Finally, you will need to call this function whenever the homepage is refreshed. This can be done using the window.onload event in JavaScript, which is triggered whenever the page is loaded.