Open yihui opened 2 years ago
@yihui I don't know fully the context here but just a reminder about https://github.com/rstudio/rstudio/issues/8096 that we added in https://github.com/rstudio/blogdown/pull/496
Slightly related, but maybe another issue as the RStudio IDE could have been using specific treatment, probably meant for Quarto which uses livereload.js I think.
Anyway, you're onto it!
Yes, I do remember https://github.com/rstudio/rstudio/issues/8096 well. That helped to some extent, and we have been "cheating" in the sense that we are refreshing the RStudio viewer by ourselves, instead of letting Hugo do it. This has a few limitations:
.md
posts, and doesn't work when Rmd is automatically rendered to .md
or .html
on save. For this problem, I can provide an ugly workaround, though (watch for changes in .md
/.html
by myself and refresh viewer if necessary).--navigateToChanged
doesn't work. For this problem, I don't see any workaround on my side.Originally Hugo had a bug (https://github.com/gohugoio/hugo/pull/6698) so there was no hope that its livereload.js
could work on RStudio Server. It has been fixed later. Now I know how to make it work, but I ran into this RStudio Server bug and I don't see a possible workaround. Let's see if the Pro team could fix it: https://github.com/rstudio/rstudio-pro/issues/4012
Unfortunately this doesn't work because I ran into an RStudio Server problem that I can't work around. The problem can be reproduced in the following steps. First create a new site and serve it:
The default port is 4321. We can fetch
livereload.js
successfully from Hugo server via this port:However, it can no longer be correctly loaded if we try to load it via the translated URL (I substituted random strings with
xxxxxx
):It doesn't work either if we paste the URL in the web browser's address bar. By comparison, all other assets work well, e.g.,
https://xxxxxx.app.rstudio.cloud/p/xxxxxx/css/main.css
. Also note that if we try to accesslivereload.js
without the.js
extension, we get a status code400
(bad request) instead of the usual404
:https://xxxxxx.app.rstudio.cloud/p/xxxxxx/livereload
It seems that RStudio Server has a special routing mechanism for the filename
livereload.js
no matter if this file is served by which server (in this case, Hugo). This interference prevents Hugo's LiveReload from working. I wonder if this is a bug of RStudio Server.