Sign in

    moonblox-cli

    MoonBlox command-line tool

    markdown
    ssg
    moonbit
    site-generator
    Download zip
    Author
    Version
    0.2.0
    License
    Apache-2.0
    Last updated
    3 months ago
    Downloads
    25

    #MoonBlox CLI

    Command-line tool for MoonBlox, a Markdown-first programmable site generator powered by MoonBit.

    #Prerequisites

    • MoonBit toolchain (latest stable)
    • Moon's binary directory on your PATH:

      export PATH="$HOME/.moon/bin:$PATH"

    #Install

    moon install xz-xuezhe/moonblox-cli

    This installs the moonblox-cli binary globally.

    #Quick Start

    moonblox-cli init my-site cd my-site moonblox-cli serve

    Open http://localhost:3000. Edit any Markdown file — the browser reloads automatically.

    #Commands

    #init — scaffold a new project

    moonblox-cli init <dir> [options]

    By default, init launches an interactive TUI that guides you through project setup (name, theme, components).

    Options:

    FlagDescription
    --headless, -HSkip interactive TUI (for CI / scripts)
    --theme, -t <name>Project theme: blog (default) or docs
    --empty, -ESkip generating sample content
    --quiet, -qSuppress non-essential output

    Examples:

    moonblox-cli init . # TUI in current directory moonblox-cli init my-blog --headless # scaffold in CI, blog theme moonblox-cli init my-docs -t docs -H # scaffold docs theme, no TUI moonblox-cli init my-site -H -E # empty scaffold, no sample content

    The scaffolded project includes:

    my-site/ moonblox.json → site configuration posts/ → Markdown content (blog theme) components/ → selected built-in components theme/base.css → global styles _moonblox/ → generated MoonBit project (build target)

    #build — build static site

    moonblox-cli build [dir]

    Parses Markdown, resolves components, and compiles to dist/ — a complete static site ready for deployment. Defaults to the current directory.

    #serve — dev server with live reload

    moonblox-cli serve [dir] [--port <port>]

    Starts a development server at http://localhost:3000 with:

    • Live reload — changes to Markdown files trigger automatic rebuild and browser refresh via WebSocket.
    • Incremental builds — unchanged files are skipped, debug builds are used for faster iteration.

    Options:

    FlagDescription
    --port, -p <port>Server port (default: 3000)

    #Project Configuration

    Site settings live in moonblox.json at the project root:

    { "input": "posts", "output": "dist", "components": "components", "theme": "blog" }

    #Documentation

    #License

    BroadcastMsg

    pub(all) enum BroadcastMsg {
    Building
    Reload
    BuildFailed(String)
    } derive(
    Debug
    )

    BuildCache

    type BuildCache

    ChangeType

    type ChangeType

    SiteConfig

    type SiteConfig

    StructuredBlockInfo

    type StructuredBlockInfo

    build

    async fn build(dir : String, dev_mode? : Bool) -> Bool

    moonblox build — generate temp project in _moonblox/, compile, assemble output

    double_to_string

    fn double_to_string(n : Double) -> String

    Serialize a double value as a MoonBit double literal. Ensures whole numbers get .0 suffix.

    escape_string

    fn escape_string(s : String) -> String

    Escape a string for embedding in a MoonBit string literal. Handles \, ", \n, \t, \r.

    generate_main_mbt

    fn generate_main_mbt(doc :
    Document
    ) -> String

    indent_str

    fn indent_str(n : Int) -> String

    Generate indentation string of 2*n spaces.

    init_tui

    async fn init_tui(default_dir? : String) -> String?

    scaffold

    fn scaffold(dir : String, theme? : String, components? : Array[String], quiet? : Bool, empty? : Bool) -> Result[Unit, String]

    MoonBlox scaffold — moonblox-cli init <dir>

    serialize_align

    fn serialize_align(align :
    TableAlign
    ) -> String

    Serialize a TableAlign

    serialize_block

    fn serialize_block(block :
    Block
    , indent : Int) -> String

    Serialize a single Block with given indent.

    serialize_blocks

    fn serialize_blocks(blocks : Array[
    Block
    ], indent : Int) -> String

    Serialize an array of @ast.Block with given indent.

    serialize_cell

    fn serialize_cell(cell :
    BlockTableCell
    , indent : Int) -> String

    Serialize a BlockTableCell

    serialize_document

    fn serialize_document(doc :
    Document
    ) -> String

    Serialize a Document to a MoonBit expression string. Returns code like: @ast.Document::{ children: [...], meta: Map([("title", "Hello")]) }

    serialize_emphasis

    fn serialize_emphasis(m :
    EmphasisMarker
    ) -> String

    Serialize an EmphasisMarker

    serialize_hardbreak

    fn serialize_hardbreak(s :
    HardBreakStyle
    ) -> String

    Serialize a HardBreakStyle

    serialize_inline

    fn serialize_inline(inline :
    Inline
    , indent : Int) -> String

    Serialize @ast.Inline with given indent.

    serialize_inlines

    fn serialize_inlines(inlines : Array[
    Inline
    ], indent : Int) -> String

    Serialize an array of @ast.Inline with given indent.

    serialize_list_item

    fn serialize_list_item(item :
    ListItem
    , indent : Int) -> String

    Serialize a ListItem

    serialize_md_inlines

    fn serialize_md_inlines(inlines : Array[
    Inline
    ], _indent : Int) -> String

    Serialize an array of @markdown.Inline with given indent.

    serialize_span

    fn serialize_span(span :
    Span
    ) -> String

    Serialize a Span

    serialize_string_map

    fn serialize_string_map(m : Map[String, String], _indent : Int) -> String

    Serialize a Map[String, String] to a MoonBit expression.

    serialize_value

    fn serialize_value(v :
    Value
    , indent : Int) -> String

    Serialize a Value to a MoonBit expression.

    serialize_value_map

    fn serialize_value_map(m : Map[String,
    Value
    ], _indent : Int) -> String

    Serialize a Map[String, Value] to a MoonBit expression.

    serve

    async fn serve(dir : String, port : Int) -> Unit

    moonblox serve — dev server with file watching and live reload