How mrxiaozhuox/karaty works
Project type and purpose
• Karaty is a Rust-based static site framework and WASM-powered SPA for blogs & docs, built on Dioxus.
• At build time it runs a CLI tool (karaty crate) that reads configs and source content; at runtime it serves a single .wasm UI that fetches and renders Markdown.
File structure
• Top-level crates/examples:
• karaty/ – the main application (binary + library)
• blueprint/, docsite/, template/ – example/template crates demonstrating custom themes or docs sites
• karaty/ substructure:
• src/config.rs – loads karaty.toml
• src/utils/markdown.rs – parses Markdown
• src/utils/template_loader.rs – loads Dioxus templates
• src/hooks/, src/components/, src/pages/ – Dioxus UI modules
• public/ data and asset outputs for runtime fetch
• Build/deploy infrastructure:
• .github/workflows/*.yml – CI/CD pipelines
• forked.py, version.py – utility scripts
• Cargo.toml files in each crate
Extract insights from the README
• Single .wasm file delivers dynamic content without rebuild
• Config via karaty.toml controls site routing & templates
• Exported static files deployable to GitHub Pages or any static server
• Extensible via Dioxus templates and custom crates
Main components
a. Build-time pipeline (CLI tool)
• Input: karaty.toml config + Markdown source under karaty/data/
• Processing: Rust binary (karaty crate)
– Config loader → data source scanner → Markdown parser → template assembler
• Output: public/ directory + index.html + karaty.wasm + assets
b. Runtime (Browser)
• Dioxus WASM frontend (karaty.wasm)
• Fetches Markdown/JSON content from public/data/
• Renders pages via Dioxus components (nav, markdown, footer, etc.)
c. Example/template crates
• blueprint, docsite, template
• Plug into the build process as custom themes or site examples
d. Deployment targets
• GitHub Pages (via 404.html trick)
• Any static file server
Relationships & data flows
• Dependencies: CLI relies on Dioxus-CLI, Serde, TOML/JSON, Markdown library; Frontend uses Dioxus components & hooks
Architectural patterns & principles
• Modular multi-crate workspace (core + examples)
• Clear separation of concerns:
• Build-time static site generator vs. runtime WASM SPA
• Plugin-style templating (users supply custom Dioxus UIs)
• Data-driven routing: config file drives URL mapping
Relevant technologies & frameworks
• Rust (Cargo)
• Dioxus (WASM UI)
• Markdown, TOML, JSON
• GitHub Actions (CI/CD)
• Tailwind CSS (via public/assets/tailwind)