moonpress

    A MoonBit-first static site and documentation generator for reusable project docs.

    static-site-generator
    documentation
    markdown
    moonbit
    Download zip
    Author
    Version
    0.1.0
    License
    MIT
    Last updated
    3 months ago
    Downloads
    34

    No dependencies

    #MoonPress

    MoonPress is a MoonBit-first static site and documentation generator. It is designed for MoonBit library authors who want to turn Markdown notes, examples, and package metadata into a small, fast, reusable documentation website.

    #Goals

    • Generate static documentation sites from Markdown files.
    • Provide simple routing, page metadata, navigation, and HTML rendering.
    • Keep the core implementation in MoonBit, with a CLI suitable for project automation.
    • Offer a polished sample site that can be used as the competition demo.

    #Phase 1 Scope

    This repository starts with the reusable core model, route helpers, a small Markdown rendering layer, and an initial CLI entry point. The next milestones will add filesystem scanning, front matter parsing, theme assets, local preview, search index generation, and integration tests.

    #Usage

    moon run src/cmd/moonpress

    The default command builds the sample docs/ directory into dist/.

    After the JS backend artifact is built, custom input, output, base URL, and preview commands can be used directly with Node:

    node _build/js/debug/build/cmd/moonpress/moonpress.js build docs --out site node _build/js/debug/build/cmd/moonpress/moonpress.js build docs --out site --base-url https://example.com/moonpress/ node _build/js/debug/build/cmd/moonpress/moonpress.js dev docs --out site --port 8080 node _build/js/debug/build/cmd/moonpress/moonpress.js clean --out site

    Expected output includes dist/index.html, a guide page, dist/search-index.json, dist/sitemap.xml, copied assets under dist/assets/, and dist/moonpress-manifest.txt.

    The sample site is bilingual. English pages are emitted at the site root, and Chinese pages are emitted under dist/zh/. Open dist/index.html or dist/zh/index.html to try the language switcher.

    #Quality Gates

    The project is expected to pass the current MoonBit toolchain checks:

    moon check moon fmt --check moon info moon test

    The CI workflow also attempts the review-required moon fmt --deny-warn and moon info --deny-warn commands first. If the installed stable MoonBit toolchain does not support those flags yet, it falls back to the current stable equivalents above.

    #Publishing

    The module name is hua1104/moonpress, and the repository field points to https://github.com/hua1104/moonpress.git. To publish after logging in to mooncakes.io:

    moon login moon package moon publish

    #Project Status

    Competition application phase. The repository is organized as a reusable MoonBit package plus CLI package. The core can plan routes, parse page metadata, render HTML, generate navigation and pager links, produce a search index, generate a sitemap, build bilingual output, write a real dist/ directory from docs/, and serve a local preview through the CLI package.

    BuildResult

    pub(all) struct BuildResult {
    files : Array[OutputFile]
    page_count : Int
    }

    Document

    pub(all) struct Document {
    source_path : String
    route : String
    front_matter : FrontMatter
    body : String
    }

    FrontMatter

    pub(all) struct FrontMatter {
    title : String
    description : String
    order : Int
    draft : Bool
    }

    pub(all) struct NavItem {
    title : String
    route : String
    depth : Int
    }

    OutputFile

    pub(all) struct OutputFile {
    path : String
    content : String
    }

    PagePlan

    pub(all) struct PagePlan {
    source_path : String
    route : String
    output_path : String
    title : String
    description : String
    order : Int
    lang : String
    draft : Bool
    }

    PageSource

    pub(all) struct PageSource {
    path : String
    source : String
    }

    RenderedPage

    pub(all) struct RenderedPage {
    route : String
    title : String
    html : String
    }

    SearchEntry

    pub(all) struct SearchEntry {
    title : String
    route : String
    description : String
    text : String
    }

    SiteConfig

    pub(all) struct SiteConfig {
    title : String
    description : String
    base_url : String
    }

    build_manifest

    fn build_manifest(result : BuildResult) -> String

    build_search_index

    fn build_search_index(pages : Array[PagePlan], sources : Array[PageSource]) -> String

    build_site

    fn build_site(sources : Array[PageSource]) -> BuildResult

    build_site_for_lang

    fn build_site_for_lang(sources : Array[PageSource], config : SiteConfig, lang : String) -> BuildResult

    build_site_with_config

    fn build_site_with_config(sources : Array[PageSource], config : SiteConfig) -> BuildResult

    build_sitemap

    fn build_sitemap(pages : Array[PagePlan], base_url : String) -> String

    collect_pages

    fn collect_pages(sources : Array[PageSource]) -> Array[PagePlan]

    collect_pages_for_lang

    fn collect_pages_for_lang(sources : Array[PageSource], lang : String) -> Array[PagePlan]

    compact_text

    fn compact_text(input : String) -> String

    default_config

    fn default_config() -> SiteConfig

    default_stylesheet

    fn default_stylesheet() -> String

    empty_front_matter

    fn empty_front_matter() -> FrontMatter

    escape_html

    fn escape_html(input : String) -> String

    escape_json

    fn escape_json(input : String) -> String

    has_front_matter

    fn has_front_matter(input : String) -> Bool

    localized_href

    fn localized_href(lang : String, route : String) -> String

    merge_build_results

    fn merge_build_results(results : Array[BuildResult]) -> BuildResult

    fn navigation_from_pages(pages : Array[PagePlan]) -> Array[NavItem]

    normalize_route

    fn normalize_route(path : String) -> String

    page_shell

    fn page_shell(title : String, body : String) -> String

    page_shell_with_navigation

    fn page_shell_with_navigation(title : String, navigation : String, body : String) -> String

    fn page_shell_with_navigation_and_footer(title : String, lang : String, navigation : String, body : String, footer : String) -> String

    plan_page

    fn plan_page(path : String, source : String) -> PagePlan

    read_description

    fn read_description(input : String) -> String

    read_draft

    fn read_draft(input : String) -> Bool

    read_lang

    fn read_lang(input : String) -> String

    read_order

    fn read_order(input : String) -> Int

    read_title

    fn read_title(input : String) -> String

    render_document

    fn render_document(path : String, source : String) -> RenderedPage

    render_inline

    fn render_inline(input : String) -> String

    render_language_switcher

    fn render_language_switcher(current_lang : String, route : String) -> String

    render_markdown

    fn render_markdown(input : String) -> String

    render_page

    fn render_page(title : String, markdown : String) -> String

    render_page_with_chrome

    fn render_page_with_chrome(title : String, lang : String, navigation : String, markdown : String, footer : String) -> String

    render_page_with_navigation

    fn render_page_with_navigation(title : String, navigation : String, markdown : String) -> String

    render_pager

    fn render_pager(pages : Array[PagePlan], index : Int) -> String

    render_pager_for_lang

    fn render_pager_for_lang(pages : Array[PagePlan], index : Int, lang : String) -> String

    render_sidebar

    fn render_sidebar(items : Array[NavItem]) -> String

    render_sidebar_for_lang

    fn render_sidebar_for_lang(items : Array[NavItem], lang : String) -> String

    route_depth

    fn route_depth(route : String) -> Int

    route_to_output_path

    fn route_to_output_path(route : String) -> String

    search_entry_json

    fn search_entry_json(entry : SearchEntry) -> String

    strip_front_matter

    fn strip_front_matter(input : String) -> String

    version

    fn version() -> String

    Powered by MoonBit

    Site sourceReport issueModulesSkillsBuild queueStatistics

    © 2026 mooncakes.io