Skip to content

Commit

Permalink
Merge pull request #2 from barelyhuman/feat/live-reload
Browse files Browse the repository at this point in the history
feat: Live Server
  • Loading branch information
barelyhuman authored Jul 1, 2023
2 parents 0d0ce8b + 817139f commit 3549160
Show file tree
Hide file tree
Showing 6 changed files with 384 additions and 117 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ docs: build
./alvu --path="docs" --baseurl="/alvu/" --highlight --hard-wrap=false

docs_dev: build
ls docs/**/* | entr -cr ./alvu --highlight --hard-wrap=false --serve --path='./docs'
./alvu --highlight --hard-wrap=false --serve --path='./docs'

pages: docs
rm -rf alvu
Expand Down
35 changes: 35 additions & 0 deletions docs/pages/04-dev-server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Development Server

The tool comes with it's own dev server (since v0.2.4), and can be used to run a
simple file server for the output folder.

It's as simple as running the following command

```sh
$ alvu --serve
# short for
$ alvu --serve --port=3000
```

## Live Reload

<small>Added in `v0.2.9`</small>

There's no changes that you need to do, just upgrade your installation to
`v0.2.9`

#### What's to be expected

- Will reload on changes from the directories `pages`, `public` , or if you
changed them with flags then the respective paths will be watched instead

- The rebuilding process is atomic and will recompile a singular file if that's
all that's changed instead of compiling the whole folder. This is only true
for files in the `pages` directory, if any changes were made in `public`
directory then the whole alvu setup will rebuild itself again.

#### Caveats

- `./hooks` are not watched, this is because hooks have their own state and
involve a VM, the current structure of alvu stops us from doing this but
should be done soon without increasing complexity or size of alvu itself.
39 changes: 19 additions & 20 deletions docs/pages/_layout.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>alvu | documentation</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="{{.Meta.BaseURL}}styles.css" />
</head>

<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>alvu | documentation</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600&display=swap"
rel="stylesheet" />
<link rel="stylesheet" href="{{.Meta.BaseURL}}styles.css">
</head>

<body>
{{.Content}}
<footer class="container">
Built with <a href="http://github.com/barelyhuman/alvu">alvu</a>
</footer>
</body>

<body>
{{.Content}}
<footer class="container">
Built with <a href="http://github.com/barelyhuman/alvu">alvu</a>
</footer>
</body>
</html>
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ go 1.18
require (
github.com/barelyhuman/go v0.2.1
github.com/cjoudrey/gluahttp v0.0.0-20201111170219-25003d9adfa9
github.com/fsnotify/fsnotify v1.6.0
github.com/otiai10/copy v1.9.0
github.com/vadv/gopher-lua-libs v0.4.1
github.com/yuin/goldmark v1.5.4
github.com/yuin/goldmark-highlighting v0.0.0-20220208100518-594be1970594
github.com/yuin/gopher-lua v1.1.0
golang.org/x/net v0.0.0-20200202094626-16171245cfb2
gopkg.in/yaml.v3 v3.0.1
layeh.com/gopher-json v0.0.0-20201124131017-552bb3c4c3bf
)

require (
github.com/alecthomas/chroma v0.10.0 // indirect
github.com/dlclark/regexp2 v1.4.0 // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
golang.org/x/sys v0.0.0-20220908164124-27713097b956 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
)
6 changes: 5 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
Expand Down Expand Up @@ -114,6 +116,7 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -128,8 +131,9 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956 h1:XeJjHH1KiLpKGb6lvMiksZ9l0fVUh+AmGcm0nOMEBOY=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
Expand Down
Loading

0 comments on commit 3549160

Please sign in to comment.