Mountable Mars middleware for static site generation
deps: mars + markdown + luna (no edge to sol)// moon.mod.json
{
"deps": {
"mizchi/astra": "0.20.0",
"mizchi/mars": "0.3.10",
"mizchi/luna": "0.20.0"
}
}moon install mizchi/astra/cmd/astra # → $MOON_HOME/bin/astra
# or via npm
pnpm add -g @luna_ui/astra # 0.20.0import "mizchi/astra/middleware" as middleware
import "mizchi/mars" as mars
async fn main {
let cfg = @astra.SsgConfig::default()
let mw = @middleware.create(cfg, cwd=".")
let app = @mars.Server::new()
app.all("/*", mw.handler())
app.listen(port=3000)
}# Dev server against the current directory's docs/ tree
astra dev --port 3000
# Static dump (writes <out>/<url>/index.html for every page URL)
astra build --out ./distpub(all) struct BuildContext {
config : SsgConfig
pages : Array[PageMeta]
sidebar : Array[SidebarGroup]
cwd : String
doc_tree : DocumentTree?
is_dev : Bool
}pub(all) struct CssUtilitiesConfig {
enabled : Bool
split : Bool
inline_threshold : Int
source_dirs : Array[String]
}pub(all) struct FooterConfig {
message : String?
copyright : String?
links : Array[FooterColumn]
top : Array[FooterElement]
bottom : Array[FooterElement]
} derive(ToJson, FromJson)pub(all) struct HeaderConfig {
left : Array[HeaderElement]
center : Array[HeaderElement]
right : Array[HeaderElement]
sticky : Bool
} derive(ToJson, FromJson)pub(all) struct Heading {
level : Int
text : String
id : String
}pub(all) struct IslandsConfig {
dir : String
base_path : String
}pub(all) struct MetaFilesConfig {
sitemap : Bool
feed : Bool
llms_txt : Bool
}pub(all) struct OgpConfig {
site_url : String?
image : String?
twitter_handle : String?
twitter_card : String?
}pub(all) struct PageInfo {
id : String
url_path : String
source_path : String
title : String
description : String
locale : String
renderer_type : RendererType
updated_at : String
content_md : String
headings : Array[Heading]
sort_key : String
}pub(all) struct PageMeta {
source_path : String
url_path : String
content_type : ContentType
renderer_type : RendererType
frontmatter : Frontmatter
last_modified : String?
locale : String
canonical_path : String
sort_key : String
}fn PageMeta::new(source_path : String, url_path : String, content_type? : ContentType, renderer_type? : RendererType, locale? : String, canonical_path? : String, sort_key? : String) -> PageMetapub(all) struct SidebarGroup {
text : String
link : String?
collapsed : Bool
items : Array[SidebarItem]
} derive(ToJson, FromJson)pub(all) struct SiteInfo {
title : String
description : String
base_url : String
language : String
updated_at : String
}pub(all) struct SsgConfig {
docs_dir : String
output_dir : String
title : String
base_url : String
nav : Array[NavItem]
sidebar : SidebarConfig
islands : IslandsConfig?
theme : ThemeConfig
navigation : NavigationConfig
i18n : I18nConfig
exclude : Array[String]
trailing_slash : Bool
ogp : OgpConfig
ogp_text : String?
head_snippets : Array[String]
body_snippets : Array[String]
prod_body_snippets : Array[String]
sanitize_html : Bool
deploy_target : DeployTarget
spa_routes : Array[String]
components_dir : String?
css_utilities : CssUtilitiesConfig?
meta_files : MetaFilesConfig
}pub(all) struct ThemeConfig {
primary_color : String?
secondary_color : String?
accent_color : String?
success_color : String?
warning_color : String?
error_color : String?
text_color : String?
text_muted_color : String?
heading_color : String?
link_color : String?
link_hover_color : String?
background_color : String?
surface_color : String?
sidebar_bg_color : String?
input_bg_color : String?
code_bg_color : String?
border_color : String?
focus_ring_color : String?
logo : String?
header : HeaderConfig?
footer : FooterConfig?
social_links : Array[SocialLink]
}fn build_sort_key(path : String) -> Stringfn compare_strings_lex(a : String, b : String) -> Intfn detect_locale_from_path(path : String, i18n : I18nConfig, trailing_slash? : Bool) -> (String, String)fn file_to_url_path(file_path : String, trailing_slash? : Bool) -> Stringfn get_filename(path : String) -> Stringfn parse_numeric_prefix(name : String) -> (Int, String)fn replace_filename(path : String, new_filename : String) -> Stringfn resolve_base_url(base_url : String, path : String) -> Stringfn strip_numeric_prefixes(path : String) -> Stringfn url_to_output_path(url_path : String) -> StringInstall
Download zipMountable Mars middleware for static site generation