Skip to content

feat: add inkssg serve with live reload#7

Merged
lucasnevespereira merged 2 commits into
mainfrom
feat/serve
May 3, 2026
Merged

feat: add inkssg serve with live reload#7
lucasnevespereira merged 2 commits into
mainfrom
feat/serve

Conversation

@lucasnevespereira

Copy link
Copy Markdown
Member

Summary

Adds inkssg serve — a local dev server that builds the site, serves it on http://localhost:3000, watches sources, and reloads the browser on every change. Closes the first item under v0.2 in ROADMAP.md.

What's in it

  • inkssg.Serve(dir, opts...) library entry point.
  • inkssg serve [path] [--addr :port] CLI command.
  • Recursive fsnotify watcher with 100ms debounce. Ignores the output dir and dotfiles. Picks up new subdirectories as they're created.
  • HTTP file server with an HTML injector that adds a tiny SSE-driven reload script before </body>. Non-HTML responses pass through untouched.
  • SSE endpoint at /__inkssg/reload with a 30s keep-alive ping. One broadcast per successful rebuild.
  • Graceful shutdown on SIGINT/SIGTERM with a 2s server drain.

Only one new dependency: github.com/fsnotify/fsnotify.

Smoke tested

  • go run ./cmd/inkssg serve examples/minimal --addr :3456200 OK, reload script present in served HTML.
  • touch examples/minimal/pages/index/content.md↻ rebuilt in 2ms in server log, SSE clients receive reload.
  • Ctrl-C exits cleanly.

Test plan

  • go build ./... passes
  • go vet ./... passes
  • inkssg serve examples/minimal builds and serves
  • Editing pages/<x>/content.md triggers a rebuild and reload
  • Editing a local theme file triggers a rebuild and reload
  • Editing ink.yaml triggers a rebuild and reload
  • Creating a new page directory while the server is running gets picked up
  • --addr :4000 overrides the default port
  • Ctrl-C exits within ~2s

@lucasnevespereira lucasnevespereira merged commit 71bffbe into main May 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant