Skip to content

Commit eda5be9

Browse files
committed
feat: add reload-on-change to serve
1 parent 679a6b8 commit eda5be9

File tree

5 files changed

+630
-201
lines changed

5 files changed

+630
-201
lines changed

data/theme/markbook.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* global fuse, EventSource */
2-
function togglesearch() {
2+
function togglesearch () {
33
var searchbar = document.getElementById('searchbar')
44
var button = document.querySelector('span[aria-controls="searchbar"]')
55
var enabled = button.getAttribute('aria-expanded') === 'true'
@@ -13,7 +13,7 @@ function togglesearch() {
1313
}
1414
}
1515

16-
function togglesidebar() {
16+
function togglesidebar () {
1717
var sidebar = document.getElementById('sidebar')
1818
var content = document.getElementById('content')
1919
var button = document.querySelector('span[aria-controls="sidebar"]')
@@ -31,7 +31,7 @@ function togglesidebar() {
3131
}
3232
}
3333

34-
function oninput(evt) {
34+
function oninput (evt) {
3535
const results = fuse
3636
.search(evt.target.value)
3737
.filter(({ matches }) => matches && matches.length)
@@ -82,7 +82,7 @@ function oninput(evt) {
8282
}
8383
}
8484

85-
function onload() {
85+
function onload () {
8686
var searchbar = document.querySelector('span[aria-controls="searchbar"]')
8787
var sidebar = document.querySelector('span[aria-controls="sidebar"]')
8888
var search = document.getElementById('searchbar')
@@ -104,10 +104,15 @@ function onload() {
104104

105105
const sse = new EventSource('/sse')
106106
sse.addEventListener('reload', e => {
107-
console.log('Received')
108-
console.log(e.data)
109-
// window.location.reload(true)
107+
console.log('reload')
108+
window.location.reload(true)
110109
})
110+
/*
111+
sse.addEventListener('error', e => {
112+
console.log('error')
113+
sse.close()
114+
})
115+
*/
111116
}
112117

113118
window.addEventListener('DOMContentLoaded', onload)

doc/src/README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22

33
The user and developer guide to Markbook.
44

5-
**Markbook** is a command-line tool that allows writers to author books written
6-
in CommonMark. It shares many concepts and similarities with both [GitBook] and
7-
[mdBook].
5+
**Markbook** is a command-line tool that allows writers to author books written in CommonMark. It shares many concepts and similarities with both [GitBook] and [mdBook].
86

9-
This very guide is written in CommonMark, to serve as an example of how to use
10-
markbook.
7+
This very guide is written in CommonMark, to serve as an example of how to use markbook.
118

12-
Markbook is free and open source under the MIT license. The source code is
13-
available on GitHub at <https://github.com/Symbitic/markbook>. Feature requests,
14-
issues, and pull requests are all welcome.
9+
Markbook is free and open source under the MIT license. The source code is available on GitHub at <https://github.com/Symbitic/markbook>. Feature requests, issues, and pull requests are all welcome.
1510

1611
[gitbook]: https://www.gitbook.com/
1712
[mdbook]: https://github.com/rust-lang-nursery/mdBook

0 commit comments

Comments
 (0)