blogatto/dev

Development server tool for Blogatto.

Types

A development server for Blogatto. This will serve the generated blog and watch for file changes to trigger rebuilds.

pub type DevServer(msg) {
  DevServer(
    after_build: option.Option(fn() -> Result(Nil, String)),
    before_build: option.Option(fn() -> Result(Nil, String)),
    build_command: String,
    config: config.Config(msg),
    port: Int,
    host: String,
    live_reload: Bool,
  )
}

Constructors

  • DevServer(
      after_build: option.Option(fn() -> Result(Nil, String)),
      before_build: option.Option(fn() -> Result(Nil, String)),
      build_command: String,
      config: config.Config(msg),
      port: Int,
      host: String,
      live_reload: Bool,
    )

    Arguments

    after_build

    An optional function to run after each build. This can be used to perform any tasks after the build command is run, such as running tailwind or other post-build tasks. (default: None)

    before_build

    An optional function to run before each build. This can be used to perform any setup or cleanup tasks before the build command is run. (default: None)

    build_command

    Build command to build the blog. (default: “gleam run”)

    config

    Blogatto build config to use for knowing which files to watch.

    port

    port to listen on. (default: 3000)

    host

    Host to listen on. (default: “127.0.0.1”)

    live_reload

    Inject the live reload script into the generated HTML pages. (default: true)

Values

pub fn after_build(
  server: DevServer(msg),
  after_build: fn() -> Result(Nil, String),
) -> DevServer(msg)

Set a function to run after each build. This can be used to perform any tasks after the build command is run, such as running tailwind or other post-build tasks.

pub fn before_build(
  server: DevServer(msg),
  before_build: fn() -> Result(Nil, String),
) -> DevServer(msg)

Set a function to run before each build. This can be used to perform any setup or cleanup tasks before the build command is run.

pub fn build_command(
  server: DevServer(msg),
  build_command: String,
) -> DevServer(msg)

Set the build command to use for building the blog. This should be a command that can be run in the terminal to build the blog, such as “gleam run” or “make build”.

pub fn host(
  server: DevServer(msg),
  host: String,
) -> DevServer(msg)

Set the host to listen on.

pub fn live_reload(
  server: DevServer(msg),
  live_reload: Bool,
) -> DevServer(msg)

Set whether to inject the live reload script into the generated HTML pages.

pub fn new(config: config.Config(msg)) -> DevServer(msg)

Create a new development server with the given config and options.

pub fn port(server: DevServer(msg), port: Int) -> DevServer(msg)

Set the port to listen on.

pub fn start(
  server: DevServer(msg),
) -> Result(Nil, error.BlogattoError)

Start the development server. This will block the current thread until the server is stopped.

Search Document