moon-ssg 是一个完全使用 MoonBit 语言编写的、高性能且轻量级的静态网站与个人博客生成核心引擎。它支持通过底层的编译解析技术,将包含 Front-matter(元数据)声明的 Markdown 源文件,结合预设的 HTML 页面模板,快速、安全地编译组合输出为高可用的整站静态 HTML 文件。引擎采用无副作用的纯函数数据映射设计,具有极强的跨平台移植性与极佳的运行效率。
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
moon-ssg
moon-ssgis a MoonBit-native static site generator for small documentation sites and personal blogs. It includes a Markdown parser, HTML renderer, front matter parser, taxonomy pages, pagination, RSS, search JSON, sitemap generation, and a filesystem CLI.The project is designed for the MoonBit OSC2026 open-source track: buildable, reproducible, testable across MoonBit targets, and useful as a compact SSG foundation for the MoonBit ecosystem.
Scope
moon-ssgsupports:title,date,draft,tags,categories, plus raw metadata retention.search.json, andsitemap.xml.content/,layouts/, andstatic/intopublic/.Non-goals for the current release:
Install
Install MoonBit from the official installer, then check the toolchain:
Use the current published package from Mooncakes:
This repository checkout prepares
0.3.1as the next publishable version. After it is released to Mooncakes, usemoon add Myytsjj/moon-ssg@0.3.1.Build And Test
Current MoonBit 0.10.4 does not support
moon info --deny-warn; usemoon infoandgit diff --exit-code.Quick Start
Run the CLI:
First run creates
ssg.config.json, default content, layouts, and static CSS when missing. Output goes topublic/.Useful flags:
Library API
The pure generator API lives in
src/ssg:The Markdown package can also be used directly:
Examples
Run the pure API example:
Run the full in-memory showcase with built-in output assertions:
Run the multi-configuration matrix example:
Run the benchmark smoke workload:
The benchmark is a reproducible smoke test, not a formal performance claim. Use it to ensure the generator handles a larger in-memory source set.
Architecture
src/markdown: Markdown AST, inline parser, block parser, event conversion, and HTML renderer.src/ssg: front matter parsing, post model, page generation, pagination, taxonomy pages, RSS, search JSON, sitemap, slugging, and output escaping.src/main: filesystem CLI and argument parsing.examples/basic: minimal downstream usage of the pure API.benchmarks/main: repeatable generator workload for sanity checks.scripts/verify_acceptance.ps1: local acceptance command runner.The core generator is pure: it maps
(filename, markdown source)inputs plus templates into generated pages. Filesystem work is isolated in the CLI.CI
GitHub Actions runs on Linux, macOS, and Windows:
moon version --allmoon updatemoon fmt --checkmoon check --target allmoon check --deny-warnmoon buildmoon test --target allmoon test --deny-warnmoon infogit diff --exit-codePublishing is intentionally not part of pull-request CI because it requires a Mooncakes credential. The repository also contains a manual
workflow_dispatchpublishing workflow. ConfigureMOONCAKES_MOONBIT_COMMUNITY_TOKENas a GitHub Actions secret before using it.Acceptance Self-Check
On Windows:
For release preparation, omit
-SkipPublishDryRun:See
docs/acceptance-checklist.mdfor the full checklist.Release
moon.modversion andCHANGELOG.md.moon publish --dry-run.Do not rewrite real history to fabricate contributors, test results, CI, benchmarks, or release state.
License
MIT. See
LICENSE.References And Acknowledgements
This project is original MoonBit implementation work. It references CommonMark, Zola, Hugo, and MoonBit
moonbitlang/xat the design/API level described inTHIRD_PARTY_NOTICES.md.Thanks to the MoonBit project and community workflow templates for the build and packaging practices used by this repository.