Skip to content

Commit

Permalink
Show site generation errors prominently in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
jp7677 committed Nov 16, 2022
1 parent 5495ca4 commit ffa766f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ private fun HTML.headFragment(viewModel: PageViewModel) {
rel = "stylesheet",
href = "../" + "/style.css".asUrlRelativeTo(viewModel.url)
)

if (viewModel.includeAutoReloadJs)
script(
type = ScriptType.textJavaScript,
Expand All @@ -35,10 +36,26 @@ private fun HTML.bodyFragment(viewModel: PageViewModel, block: DIV.() -> Unit) {
pageHeader(viewModel.headerBar)

div(classes = "site-layout") {
id = "site"
menu(viewModel.menu)
div(classes = "container is-fluid has-background-white") {
block()
}
}

if (viewModel.includeAutoReloadJs)
div(classes = "container is-hidden") {
id = "hero"
div(classes = "hero is-danger mt-6") {
div(classes = "hero-body") {
p(classes = "title") {
text("Error loading workspace file")
}
p(classes = "subtitle") {
id = "hero-subtitle"
}
}
}
}
}
}
5 changes: 5 additions & 0 deletions src/main/resources/assets/js/auto-reload.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ function connectToWs() {
console.log("Site updating ...")
} else if (event.data === "site-updated") {
console.log("Site update detected, detect page content change ...")
document.getElementById("site").classList.remove("is-hidden")
document.getElementById("hero").classList.add("is-hidden")
reloadIfNeeded();
} else {
console.log(event.data)
document.getElementById("hero-subtitle").innerText = event.data
document.getElementById("site").classList.add("is-hidden")
document.getElementById("hero").classList.remove("is-hidden")
}
}
}
Expand Down

0 comments on commit ffa766f

Please sign in to comment.