# Thor — Odin Static Site Generator Thor is a static site generator written in [Odin](https://odin-lang.org), replacing Hugo for the `sbrow.github.io` blog. It lives at `./thor/` as a git subtree with its own `flake.nix`. ## Architecture ``` thor.json ← site config (title, base_url, author, params, sectionate) content/ ← markdown and HTML content files layouts/ ← Mustache templates + partials (including icons) assets/ ← CSS (Tufte-based, no build step) and JS public/ ← build output (generated) ``` ### Source files | File | Responsibility | |---|---| | `main.odin` | Entry point. Sets `context.logger`, calls `init_site`, `walk_content`, `render_site` | | `site.odin` | `Site` struct (config + arena), `init_site`, `load_site_config`, `site_merge`, `site_allocator`, `destroy_site` | | `frontmatter.odin` | JSON frontmatter parser (`{ }` delimited) | | `content.odin` | `Page` struct, content walker, page loader, cmark integration, full markdown pipeline | | `footnotes.odin` | Note definition stripping (pre-cmark) + sidenote/marginnote injection (post-cmark) | | `alerts.odin` | GitHub alert post-processor (`> [!CAUTION]` → styled blockquote) | | `emoji.odin` | Emoji shortcode expander (`:shrug:` → `¯\_(ツ)_/¯`) | | `highlight.odin` | Post-cmark Tree-sitter syntax highlighter; loads grammars/queries from Helix, caches loaded grammars, reports syntax errors with file/line | | `tree_sitter.odin` | C FFI bindings for Tree-sitter (TSParser, TSQuery, TSQueryCursor, node traversal, dlopen/dlsym) | | `sectionate.odin` | `wrap_sections` proc — splits HTML at `` wrappers | | `render.odin` | Mustache template rendering, all page types, RSS, sitemap, robots.txt, `load_partials` recursive scan | | `feed.odin` | RSS feed + sitemap XML generation | | `mustache/` | Vendored [odin-mustache](https://github.com/benjamindblock/odin-mustache) library | Icon SVGs live as HTML partials in `layouts/partials/icons/` (home, github, rss, chevron_up, star). ### Data flow ``` thor.json → init_site → Site (config + Dynamic_Arena) ↓ content/ → walk_content → []Page (with body_html from pipeline) ↓ layouts/*.html → render_site (Mustache render_in_layout) → public/ ``` ### Config system `Site` has `params: json.Value` for arbitrary user-defined data from `thor.json`. Social links and other template-only data live under `"params"`. `sectionate: bool` controls automatic `
` wrapping at `

` boundaries. ```json { "title": "...", "base_url": "...", "author": "...", "sectionate": true, "params": { "social": [ { "name": "github", "url": "...", "icon": "icons/github" } ] } } ``` Templates access params via dotted keys: `{{#params.social}}`, `{{>* icon}}`. Config precedence: `CLI flags > thor.json values > hardcoded defaults`. ### Markdown pipeline (in content.odin `load_page`) ``` raw markdown → expand_emoji (pre-cmark: :shortcode: → unicode) → strip_definitions (pre-cmark: extract [^id]: definitions) → cmark markdown_to_html (Unsafe mode for HTML passthrough) → inject_sidenotes (post-cmark: [^id] →