]> git.maquefel.me Git - brevno-suite/hugo/commit
livereload: Inject script without head or body tag
authorsatotake <doublequotation@gmail.com>
Sun, 7 Aug 2022 14:15:28 +0000 (23:15 +0900)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 7 Aug 2022 16:34:01 +0000 (18:34 +0200)
commitb017f7cb0136ee33f5d19749a15bf3365a991ac5
tree622c40237802ce9426f0b0d49d4477d8fd111422
parent7fb28085aca42ff1771c5a9d0717530c9515fa5c
livereload: Inject script without head or body tag

Currently, Hugo does not inject `livereload` script if html does not contain `<head>` or `<body>`. This sometimes happens if you create new sites without `theme` and it is hard to catch the cause soon.

This PR:

* Inject livereload script even if html does not include `<head>`, `<body>`, or `<html>`
    - Modern browsers execute scripts even if they are outside `<html>`
    - Some js frameworks (confirmed with vite) inject HRM script without `<html>` tag
* Append warning script to html if `<head>` or `<body>` is not in html
* Fix bug that livereload cannot be appended to the tags with attrs

Close #10105
transform/livereloadinject/livereloadinject.go
transform/livereloadinject/livereloadinject_test.go