Compare commits

..

4 Commits

Author SHA1 Message Date
Spencer Brower 566d6f0768 feat: Improved opengraph defaults. 2026-07-20 15:33:55 -04:00
Spencer Brower 1cb13a6a55 chore: Updated AGENTS.md. 2026-07-20 13:47:15 -04:00
Spencer Brower 5cef29e16f chore(EXTENSIONS.md): Removed future pipe plans. 2026-07-20 13:43:02 -04:00
Spencer Brower 5d8f646b31 build: Updated to latest available Odin package. 2026-07-20 12:53:06 -04:00
11 changed files with 488 additions and 164 deletions
+194 -77
View File
@@ -5,63 +5,119 @@ Thor is a static site generator written in [Odin](https://odin-lang.org), replac
## Architecture ## Architecture
``` ```
thor.json ← site config (title, base_url, author, params) thor.json ← site config (title, base_url, author, params, modules)
content/ ← markdown and HTML content files content/ ← markdown and HTML content files
layouts/ ← Mustache templates + partials (including icons) layouts/ ← Mustache templates + partials (user overrides)
assets/ ← CSS (Tufte-based), JS, fonts, images — copied/processed to public/ assets/ ← CSS (Tufte-based), JS, fonts, images
thor/defaults/ ← bundled default templates (embedded via #directory)
public/ ← build output (generated) public/ ← build output (generated)
``` ```
### Source files ### Package structure
```
thor/
├── treesitter/ # FFI types + grammar management (standalone package)
├── markdown/ # Content transformation pipeline (imports ../treesitter)
├── mustache/ # Template engine with lambdas + pipe filters
├── content.odin # Page struct, scan_content, load_page
├── render.odin # Template rendering, data structs, RSS, sitemap
├── site.odin # Config (Flags, Config_File, Site), init_site
├── minify.odin # HTML/CSS minification (imports treesitter)
├── feed.odin # RSS + sitemap generation
├── vfs.odin # Union file system (defaults → modules → site)
├── assets.odin # VFS-based asset copying
├── opengraph.odin # Open_Graph struct + og_init/og_for_page
├── frontmatter.odin # JSON frontmatter parser
├── defaults.odin # DEFAULTS_PATH constant (#directory)
├── main.odin # Entry point
└── defaults/layouts/ # Bundled default templates
```
### Source files (main package)
| File | Responsibility | | File | Responsibility |
|---|---| |---|---|
| `main.odin` | Entry point. Sets `context.logger`, calls `init_site`, `walk_content`, `render_site`. Optional Spall profiling via `SPALL` config flag. | | `main.odin` | Entry point. Sets `context.logger`, calls `init_site`, `build_vfs`, `site_load_content`, `render_site`. Optional Spall profiling via `SPALL` config flag. |
| `site.odin` | `Flags` (CLI args), `Config_File` (from `thor.json`), `Site` (runtime state + arena), `Feature` + `Markdown_Extension` bit_set enums, `DEFAULT_MARKDOWN_EXTENSIONS`, 5-step `init_site` (defaults → flags → config → apply config → apply flags), `load_config_file`, `apply_config`, `apply_cli_flags`, `parse_extension_list`, `find_config` | | `site.odin` | `Flags` (CLI), `Config_File` (thor.json), `Site` (runtime state + arena + VFS + pages + modules). `Feature` enum. 5-step `init_site`. Imports `md "markdown"` for `Extension` enum. |
| `frontmatter.odin` | JSON frontmatter parser (`{ }` delimited) | | `content.odin` | `Page` struct, `scan_content` (section-aware walk that handles leaf bundles), `load_page`, `infer_layout`. Calls `md.process()` for the markdown pipeline. |
| `content.odin` | `Page` struct, content walker, page loader, cmark integration, full markdown pipeline, `copy_assets_dir` (recursive copy with CSS minification) | | `render.odin` | Template rendering: `render_site`, `render_page_html`, `render_home_html`, `render_section`. Data structs (`Base_Data`, `Page_Data`, `Home_Data`, `Section_Data`). VFS-based template loading with fallback chain (`get_template`). |
| `footnotes.odin` | Note definition stripping (pre-cmark) + sidenote/marginnote injection (post-cmark) | | `minify.odin` | HTML/CSS minification via tree-sitter. Imports `ts "treesitter"`. |
| `alerts.odin` | GitHub alert post-processor (`> [!CAUTION]` → styled blockquote) | | `feed.odin` | RSS feed + sitemap XML. Uses `page.url` for canonical URLs. |
| `emoji.odin` | Emoji shortcode expander (`:shrug:``¯\_(ツ)_/¯`), post-cmark | | `vfs.odin` | Union file system: `VFS`, `build_vfs`, `mount_dir`, `mount_subdir`, `mount_recursive`, `vfs_get`. Layers defaults → modules → site. |
| `highlight.odin` | Post-cmark Tree-sitter syntax highlighter; statically links HTML/CSS grammars, dlopen for others; caches loaded grammars, reports syntax errors | | `assets.odin` | `copy_assets_dir` — iterates VFS entries with `assets/` prefix, minifies CSS, copies verbatim or via `os.copy_file`. |
| `tree_sitter.odin` | C FFI bindings for Tree-sitter (TSParser, TSQuery, TSQueryCursor, node traversal, dlopen/dlsym). Statically links `tree-sitter-html` and `tree-sitter-css` via Nix. | | `opengraph.odin` | `Open_Graph` struct (fields ordered per OGP spec). `og_init(site)` for site defaults, `og_for_page(site, page, base)` for page-specific OG data. |
| `sectionate.odin` | `wrap_sections` proc — splits HTML at `<h2` into `<section>` wrappers | | `frontmatter.odin` | JSON frontmatter parser (`{ }` delimited). Supports `layout` field for template override. |
| `render.odin` | Template rendering pipeline: pre-parses templates/partials once, struct-based data model (`Base_Data`/`Page_Data`/`Home_Data`/`Posts_Data`), `mustache.render()`, minification gate, RSS, sitemap, robots.txt | | `defaults.odin` | `DEFAULTS_PATH` constant, resolved at compile time via `#directory` so bundled templates ship in the binary. |
| `minify.odin` | Tree-sitter-based HTML and CSS minification (`minify_html`, `minify_css`). Strips comments, collapses whitespace, removes inter-tag spaces. Preserves `<pre>`/`<code>`/`<script>`/`<style>` content. |
| `feed.odin` | RSS feed + sitemap XML generation. Uses `strings.Builder`. `format_rfc822` uses `core:time` for date parsing. | ### Subpackages
| `mustache/` | Mustache template engine (spec-compliant, custom implementation) |
| Package | Files | Responsibility |
|---|---|---|
| `treesitter/` | `treesitter.odin` | FFI types (`Parser`, `Node`, `Query`, etc.), `@(link_prefix="ts_")` foreign bindings, grammar management (`ensure_parser`, `load_grammar`, `grammar_cache`), statically-linked HTML/CSS grammars |
| `markdown/` | `markdown.odin` | `Extension` enum, `DEFAULT_EXTENSIONS`, `process(body, ext, file_path)` — full pipeline, `parse_extension_list`, `apply_extension_config` |
| | `footnotes.odin` | `strip_definitions` (pre-cmark), `inject_notes` (post-cmark) |
| | `alerts.odin` | `inject_alerts` — GitHub alert blocks (`> [!NOTE]`) → styled blockquotes with semantic class names (`alert-note` etc.) |
| | `emoji.odin` | `expand_emoji``:shortcode:` → unicode emoji |
| | `sectionate.odin` | `wrap_sections` — splits HTML at `<h2>` into `<section>` wrappers |
| | `highlight.odin` | Syntax highlighting via tree-sitter. Imports `../treesitter`. |
| `mustache/` | See [Mustache engine](#mustache-engine) below | Template engine |
Icon SVGs live as HTML partials in `layouts/partials/icons/` (home, github, rss, chevron_up, star). Icon SVGs live as HTML partials in `layouts/partials/icons/` (home, github, rss, chevron_up, star).
### Data flow ### Data flow
``` ```
thor.json → find_config → init_site: thor.json → find_config → init_site (5-step)
1. set defaults (base_url, DEFAULT_MARKDOWN_EXTENSIONS) → build_vfs (defaults/layouts → modules → site/layouts, site/assets)
2. parse CLI flags (Flags struct) → site_load_content (scan_content + url computation)
3. load config file (Config_File from thor.json) → render_site
4. apply_config — non-empty config fields override defaults → load_partials + get_template (VFS + fallback chain)
5. apply_cli_flags — flags override config, -ext/-no-ext adjust extensions → render_page_html / render_home_html / render_section
→ Site (config + Dynamic_Arena + features: bit_set + markdown_extensions: bit_set) → optional minify_html
→ public/
content/ → walk_content → []Page (with body_html from pipeline)
layouts/*.html → parse() → mustache.Template (parsed once)
render_site → mustache.render(Page_Data, partials) → optional minify_html → public/
``` ```
### Config system ## Page struct
```odin
Page :: struct {
section: string, // "" for root, "posts", etc.
slug: string,
layout: string, // inferred or frontmatter override
permalink: string, // relative URL path
url: string, // full canonical URL (base_url + permalink)
title: string,
description: string,
date: string,
menu: string,
body_html: string,
draft: bool,
is_starred: bool,
_is_index: bool `private`,
}
```
No `Page_Type` enum — page type is inferred from section + `_is_index`. Layout is inferred via `infer_layout(section, is_index)`:
- Home (root index): `"home"`
- Section index: `"<section>_index"` (e.g. `"posts_index"`)
- Section page: singularized section (e.g. `"post"`)
- Root page: `"page"`
**Template fallback chain** (in `get_template`): for content pages, `post → page → base`; for section indexes, `posts_index → section_index → page → base`. Fallbacks logged at debug level. Frontmatter `layout` field overrides the inferred value.
## Config system
Config is split into three structs with a clear 5-step initialization flow: Config is split into three structs with a clear 5-step initialization flow:
- **`Flags`** — CLI args only. Parsed by `core:flags`. Includes path overrides, build-mode toggles, and `-ext`/`-no-ext` for markdown extension overrides. - **`Flags`** — CLI args only. Parsed by `core:flags`. Includes path overrides (`--content`, `--assets`, `--output`, `--layouts`), build-mode toggles (`-drafts`, `-watch`, `-minify`), and `-ext`/`-no-ext` for markdown extension overrides.
- **`Config_File`** — parsed from `thor.json` via `json.unmarshal_string`. Holds title, paths, `markdown_extensions` (JSON), `params` (JSON). - **`Config_File`** — parsed from `thor.json` via `json.unmarshal_string`. Holds title, paths, `markdown_extensions` (JSON), `params` (JSON), `modules` (JSON array of relative paths).
- **`Site`** — runtime state: arena, resolved config values, `features: bit_set[Feature]`, `markdown_extensions: bit_set[Markdown_Extension]`. - **`Site`** — runtime state: arena, pages, modules, VFS, `features: bit_set[Feature]`, `markdown_extensions: bit_set[md.Extension]`.
**`Feature` enum** — build-mode toggles: `Drafts`, `Minify`, `Watch`. Checked with `.Minify in site.features`. **`Feature` enum** — `Drafts`, `Minify`, `Watch`. Checked with `.Minify in site.features`.
**`Markdown_Extension` enum** — content pipeline toggles: `Emoji`, `Sidenotes`, `Alerts`, `Highlight`, `Sections`. Default is `DEFAULT_MARKDOWN_EXTENSIONS` (currently `.Emoji, .Sidenotes, .Alerts`). Configurable via: **`markdown.Extension` enum** (in the `markdown` package, not main) — `Emoji`, `Sidenotes`, `Alerts`, `Highlight`, `Sections`. Default is `md.DEFAULT_EXTENSIONS` (currently `.Emoji, .Sidenotes, .Alerts`). Configurable via:
- `thor.json`: `"markdown_extensions": { "emoji": true, "highlight": false, ... }` - `thor.json`: `"markdown_extensions": { "emoji": true, "highlight": false, ... }`
- CLI: `-ext:highlight,sections` (enable) / `-no-ext:emoji` (disable). Comma-separated, case-insensitive. - CLI: `-ext:highlight,sections` (enable) / `-no-ext:emoji` (disable). Comma-separated, case-insensitive.
@@ -74,6 +130,7 @@ Config precedence: `CLI flags > thor.json values > hardcoded defaults`.
"title": "...", "title": "...",
"base_url": "...", "base_url": "...",
"author": "...", "author": "...",
"modules": ["../path/to/module"],
"markdown_extensions": { "markdown_extensions": {
"emoji": true, "emoji": true,
"sidenotes": true, "sidenotes": true,
@@ -89,7 +146,41 @@ Config precedence: `CLI flags > thor.json values > hardcoded defaults`.
} }
``` ```
### Template system ## VFS (Union File System)
Layered directory resolution for templates and assets: `site layouts/ → module layouts/ → defaults/layouts/`.
```odin
VFS :: struct { files: map[string]VFS_Entry }
VFS_Entry :: struct { fs_path: string, data: []byte }
```
`build_vfs` mounts in reverse precedence (defaults first, site last overwrites). `DEFAULTS_PATH` resolved at compile time via `#directory`, so bundled templates ship inside the binary. Modules configured via `"modules": ["../path"]` in `thor.json` — each module contributes `layouts/` and `assets/` subdirectories. `vfs_get` lazily reads file contents on first access.
Content is **not yet in the VFS**`scan_content` still uses direct filesystem reads. (See `TODOS.md`.)
## Open Graph
`Open_Graph` struct in `opengraph.odin` with fields ordered per [ogp.me](https://ogp.me/) spec. Site defaults set via `og_init(site)` (site_name, description, default image, locale). Page-specific fields via `og_for_page(site, page, base)` (copies base, overrides url/title/type/is_article/section/published_time). Templates access via `{{og.url}}`, `{{og.title}}`, `{{#og.is_article}}`, etc.
## Markdown pipeline
Lives in the `markdown` package. Entry point: `md.process(body, ext, file_path)`. All `.html` content files skip the pipeline entirely — body is used as-is.
```
raw markdown
→ md.strip_definitions (if .Sidenotes — pre-cmark)
→ cmark markdown_to_html (Unsafe mode for HTML passthrough)
→ md.expand_emoji (if .Emoji — post-cmark)
→ md.inject_notes (if .Sidenotes — post-cmark)
→ md.inject_alerts (if .Alerts — post-cmark)
→ md.highlight_code (if .Highlight — post-cmark)
→ md.wrap_sections (if .Sections — post-cmark)
```
Each step is gated by `bit_set[md.Extension]`.
## Template system
Templates use Mustache with template inheritance (`{{<base}}` / `{{$block}}`): Templates use Mustache with template inheritance (`{{<base}}` / `{{$block}}`):
@@ -97,7 +188,7 @@ Templates use Mustache with template inheritance (`{{<base}}` / `{{$block}}`):
<!-- base.html --> <!-- base.html -->
<body>{{> nav}}{{$content}}{{/content}}{{> footer}}</body> <body>{{> nav}}{{$content}}{{/content}}{{> footer}}</body>
<!-- post.html --> <!-- page.html (content layout) -->
{{<base}} {{<base}}
{{$content}} {{$content}}
<main><article><h1>{{page_title}}</h1>{{&body}}</article></main> <main><article><h1>{{page_title}}</h1>{{&body}}</article></main>
@@ -109,50 +200,61 @@ Data is passed as **typed structs** (not `map[string]any`). Mustache resolves st
```odin ```odin
Base_Data :: struct { Base_Data :: struct {
now: datetime.DateTime, now: datetime.DateTime,
body: string, author: string,
title: string, params: json.Value,
// ... body: string,
title: string,
og: Open_Graph,
} }
Page_Data :: struct { Page_Data :: struct {
using base: Base_Data, // fields promoted via struct_get fallback using base: Base_Data, // fields promoted via reflection fallback
page_title: string,
date_iso: string,
date_display: string,
}
Home_Data :: struct {
using base: Base_Data,
pages: [dynamic]Page_Context,
}
Section_Data :: struct {
using base: Base_Data,
page_title: string, page_title: string,
// ... posts: [dynamic]Page_Context, // flat list; year grouping done in template via pipe
} }
``` ```
`render_site` pre-parses all templates and partials once (via `mustache.parse`), then reuses them for every page render. `render_site` pre-parses all partials and the base layout once (via `mustache.parse`), then per-layout templates are cached in `get_template`. Year-based grouping on section index pages is done in the template via `{{#posts | group_by year}}` (see Pipes extension below) — there is no `Year_Section` Go-side struct.
**Pipes extension**: section tags may transform the resolved value before iteration via `{{#key | op args…}}`. Pipe filters are parsed into `Node.filters` (allocator-owned by the template) and applied at render time via `apply_pipeline`, with filter results (e.g. `[dynamic]Group` from `group_by`) living in `context.temp_allocator`. Currently only `group_by <field>` is implemented; see `mustache/EXTENSIONS.md`. Used by `posts_index.html` to group posts by year without privileged Go-side data shaping. ### Pipes extension
### Markdown pipeline (in content.odin `load_page`) Section tags may transform the resolved value before iteration:
``` ```handlebars
raw markdown {{#posts | group_by year}}
→ strip_definitions (pre-cmark: extract [^id]: definitions — only if .Sidenotes enabled) {{key}}: {{#items}}{{title}}, {{/items}}
→ cmark markdown_to_html (Unsafe mode for HTML passthrough) {{/posts}}
→ expand_emoji (post-cmark: :shortcode: → unicode — only if .Emoji enabled)
→ inject_notes (post-cmark: [^id] → <label><input><span> markup — only if .Sidenotes enabled)
→ inject_alerts (post-cmark: [!TYPE] blockquotes → styled alerts — only if .Alerts enabled)
→ highlight_code (post-cmark: tree-sitter per code block — only if .Highlight enabled)
→ wrap_sections (post-cmark: wraps content in <section> at <h2> — only if .Sections enabled)
``` ```
Each step is gated by `bit_set[Markdown_Extension]`. All `.html` content files skip the pipeline entirely — body is used as-is. Currently only `group_by <field>` is implemented. Filter results live in `context.temp_allocator` (render-scoped). See `mustache/EXTENSIONS.md` for syntax details, caps (`MAX_PIPES`, `MAX_PIPE_ARGS`), and the `Group` struct shape.
### Syntax highlighting ### Comments
`page.html` includes `{{> comments}}`. The `comments.html` partial self-guards with `{{#og.is_article}}` so it only renders on article pages — no separate `is_post` flag.
## Syntax highlighting
Build-time highlighting via Tree-sitter C FFI. No client-side JavaScript. Build-time highlighting via Tree-sitter C FFI. No client-side JavaScript.
- **HTML and CSS grammars** statically linked via Nix (`mkGrammarStaticLib` in `thor/flake.nix`). Always available, no dlopen. - **HTML and CSS grammars** statically linked via Nix (`mkGrammarStaticLib` in `thor/flake.nix`). Always available, no `dlopen`.
- **Other grammars** (bash, odin, nu, etc.) loaded via `dlopen` from Helix's compiled `.so` files. - **Other grammars** (bash, odin, nu, etc.) loaded via `dlopen` from Helix's compiled `.so` files.
- Highlight queries (`.scm`) loaded from Helix's runtime directory. - Highlight queries (`.scm`) loaded from Helix's runtime directory.
- Paths hardcoded in `tree_sitter.odin` (Nix store paths, Helix-version-dependent). - Paths hardcoded in `treesitter/treesitter.odin` (`GRAPHS_PATH`, `QUERIES_PATH`) — Nix store paths, Helix-version-dependent. (See `TODOS.md`.)
- Grammar loading split: `ensure_parser` (parser only, used by minify) vs `load_grammar` (parser + query, used by highlight). - Grammar loading split: `ensure_parser` (parser only, used by minify) vs `load_grammar` (parser + query, used by highlight).
- Capture names mapped to CSS classes: `keyword``.hl-keyword`, etc. - Capture names mapped to CSS classes: `keyword``.hl-keyword`, etc.
- Atom-one-dark color theme in `main.css`. - Atom-one-dark color theme in `main.css`.
### Minification ## Minification
Optional, enabled with `-minify` flag (`.Minify` in `Feature` bit_set). Optional, enabled with `-minify` flag (`.Minify` in `Feature` bit_set).
@@ -160,17 +262,18 @@ Optional, enabled with `-minify` flag (`.Minify` in `Feature` bit_set).
- **CSS** — tree-sitter parses `.css` files in `assets/`, strips comments, collapses whitespace, trims around `{};:,`. Applied during `copy_assets_dir`. - **CSS** — tree-sitter parses `.css` files in `assets/`, strips comments, collapses whitespace, trims around `{};:,`. Applied during `copy_assets_dir`.
- Non-CSS files in `assets/` copied verbatim. - Non-CSS files in `assets/` copied verbatim.
### Memory management ## Memory management
- `Site` owns a `mem.Dynamic_Arena` - `Site` owns a `mem.Dynamic_Arena`
- `init_site` calls `mem.dynamic_arena_init(&site.arena, alignment = 64)` — the 64-byte alignment is required by Odin's map runtime (`MAP_CACHE_LINE_SIZE`) - `init_site` calls `mem.dynamic_arena_init(&site.arena)` (Odin's default alignment suffices)
- Config loading (flags + JSON) uses the arena allocator explicitly - Config loading (flags + JSON) uses the arena allocator explicitly
- `site_allocator(site)` returns the arena allocator for callers - `site_allocator(site)` returns the arena allocator for callers
- `destroy_site` frees the arena - `destroy_site` frees the arena
- `main.odin` sets `context.logger = log.create_console_logger()` — without this, all `log.*` calls are silently dropped - `main.odin` sets `context.logger = log.create_console_logger()` — without this, all `log.*` calls are silently dropped
- `context.allocator` is set to `site_allocator(&site)` in the main loop - `context.allocator` is set to `site_allocator(&site)` in the main loop
- `context.temp_allocator` freed per watch-loop iteration via `defer free_all`
### Spall profiling ## Spall profiling
Optional, compiled out by default. Enabled with `-define:SPALL=true`: Optional, compiled out by default. Enabled with `-define:SPALL=true`:
@@ -205,23 +308,25 @@ nix build # runs thor, outputs to ./result/
```bash ```bash
cd thor cd thor
odin test . # site tests (config, frontmatter, footnotes) odin test . # main package tests (site, frontmatter)
odin test . -all-packages # includes mustache spec tests odin test . -all-packages # includes mustache specs, lambdas, pipes, markdown tests
``` ```
## Mustache engine ## Mustache engine
Spec-compliant Mustache implementation at `mustache/`. See `mustache/EXTENSIONS.md` for the non-standard extensions (pipes). Spec-compliant implementation at `mustache/`. See `mustache/SPEC.md` for the implementation specification and `mustache/EXTENSIONS.md` for non-standard extensions (pipes).
### Files ### Files
| File | Responsibility | | File | Responsibility |
|---|---| |---|---|
| `mustache.odin` | Public API (`parse`, `render`, `Template`), parser (`parse_section`), renderer (`render_nodes`), template inheritance (`merge_block_overrides`) | | `mustache.odin` | Public API (`parse`, `render`, `Template`), parser (`parse_section` with allocator threading), renderer (`render_nodes`), template inheritance (`merge_block_overrides`), `delete_template`/`delete_partials` |
| `tokenizer.odin` | Tokenizer (template string → `[]Token`), standalone whitespace detection | | `tokenizer.odin` | Tokenizer (template string → `[]Token`), standalone whitespace detection |
| `data.odin` | Reflection-based data model: `effective` (union/distinct peeling), `lookup_in`, `resolve_name`, `is_truthy`, `any_to_string`, `list_info`, `write_value` | | `data.odin` | Reflection-based data model: `base_value` (peels union/any/nested-any layers), `lookup_in` (structs + maps, handles `Type_Info_Any` value kind in maps), `resolve_name`, `is_truthy`, `any_to_string`, `list_info`, `extract_list_element` (unwraps `[dynamic]any` element types so downstream lookups see the real value), `call_interp_lambda`/`call_section_lambda` |
| `pipes.odin` | Pipes extension: `Pipe_Filter` AST, `parse_pipeline`, `apply_pipeline`, `apply_group_by`. Stored on `Node.filters`; render-scoped results in temp allocator. | | `pipes.odin` | Pipes extension: `Pipe_Filter` AST, `parse_pipeline`, `apply_pipeline`, `apply_filter` (switch dispatch), `apply_group_by`. Stored on `Node.filters`; render-scoped results in temp allocator. |
| `spec_test.odin` | JSON spec test runner — loads `spec/specs/*.json`, runs each test case | | `spec_test.odin` | JSON spec test runner — loads `spec/specs/*.json`, runs each test case |
| `lambda_test.odin` | Spec lambda tests |
| `pipes_test.odin` | Pipe filter tests |
### Architecture ### Architecture
@@ -233,23 +338,34 @@ render(tmpl, data, partials) → render_nodes (walks flat node array against con
- **Two-phase API**: `parse()` produces a reusable `Template`, `render()` walks it against data. Templates parsed once, rendered many times. - **Two-phase API**: `parse()` produces a reusable `Template`, `render()` walks it against data. Templates parsed once, rendered many times.
- **Flat `[dynamic]Node` array** with `first_child`/`child_count` indices — pre-order layout. - **Flat `[dynamic]Node` array** with `first_child`/`child_count` indices — pre-order layout.
- **Context stack**: `^[dynamic]any` with `append`/`pop` for section push/pop. - **Context stack**: `^[dynamic]any` with `append`/`pop` for section push/pop.
- **`effective(a)`** peels Named/Distinct/Union layers (including `json.Value`). - **`base_value`** peels Named/Distinct/Union layers (including `json.Value`). Also unwraps nested `any`-of-`any` (which occurs when `map[string]any` values are read via runtime map internals).
- **`lookup_in`** resolves keys on structs (via `reflect.struct_field_value_by_name` with `allow_using = true`) and maps (via runtime map internals). - **`lookup_in`** resolves keys on structs (via `reflect.struct_field_value_by_name` with `allow_using = true`) and maps. Detects `Type_Info_Any` value kind in maps and reads the inner any directly to avoid double-wrap.
- **Template inheritance**: `{{<parent}}` loads parent from partials, `{{$block}}` defines overridable sections. `merge_block_overrides` propagates overrides through multi-level chains. - **Template inheritance**: `{{<parent}}` loads parent from partials, `{{$block}}` defines overridable sections. `merge_block_overrides` propagates overrides through multi-level chains.
- **Dynamic partial names**: `{{>*key}}` resolves partial name from data context at render time. - **Dynamic partial names**: `{{>*key}}` resolves partial name from data context at render time.
### Lambdas
Spec-compliant. Stored as `any` values in the data context.
- **Interpolation lambdas**: `proc() -> string`, `proc() -> int`, `proc() -> bool` — called via `call_interp_lambda`, result stringified and escaped.
- **Section lambdas**: `proc(string) -> string`, `proc(string) -> int`, `proc(string) -> bool` — called via `call_section_lambda` with the raw section text (`node.content`). String result is re-parsed as mustache and rendered against the current context stack.
### Pipes
`{{#key | op args…}}…{{/key}}`. Stored as `[dynamic; MAX_PIPES]Pipe_Filter` on each `Node` (fixed-cap inline storage, no per-tag heap allocation at parse time). Applied in the renderer via `apply_pipeline` before truthiness check. Currently only `group_by <field>` is implemented (returns `[dynamic]Group` where `Group{key, items}`). See `mustache/EXTENSIONS.md`.
### Not implemented ### Not implemented
- Lambdas (`~lambdas.json`)
- Set delimiters (`{{= =}}`, `delimiters.json`) - Set delimiters (`{{= =}}`, `delimiters.json`)
## Known limitations ## Known limitations
- cmark allocates via C malloc, not the arena. HTML output leaks until process exit. - cmark allocates via C malloc, not the arena. HTML output leaks until process exit (problematic in watch mode — see `TODOS.md`).
- CSS/JS cache busting uses manual `?v=N` query params instead of content hashing. - CSS/JS cache busting uses manual `?v=N` query params instead of content hashing.
- Tree-sitter grammar/query paths for dynamic grammars hardcoded in `tree_sitter.odin` (Nix store hashes, Helix-version-dependent). HTML/CSS are statically linked. - Tree-sitter grammar/query paths for dynamic grammars hardcoded in `treesitter/treesitter.odin` (Nix store hashes, Helix-version-dependent). HTML/CSS are statically linked.
- `map[string]any` not fully supported by mustache `lookup_in` — thor uses structs instead. - `map[string]any` only works through `lookup_in`'s special-case handling; thor otherwise uses structs.
- `format_f64` in mustache brute-forces shortest float representation. - `format_f64` in mustache brute-forces shortest float representation.
- Content directory not mounted in VFS (modules can ship templates/assets but not content packs yet).
## Design decisions ## Design decisions
@@ -257,6 +373,7 @@ You may never, *ever* remove `TODO:` or `FIXME:` comments. Those are for humans,
See `HUGO.md` for analysis of why thor doesn't need Hugo's shortcode context isolation. See `HUGO.md` for analysis of why thor doesn't need Hugo's shortcode context isolation.
See `mustache/PARTIAL_INDENT.md` for whitespace handling analysis. See `mustache/PARTIAL_INDENT.md` for whitespace handling analysis.
See `mustache/SPEC.md` for the original implementation specification. See `mustache/SPEC.md` for the original implementation specification.
See `mustache/EXTENSIONS.md` for non-standard extensions (pipes).
## TODO ## TODO
+6 -7
View File
@@ -6,6 +6,7 @@
- [ ] Only publish referenced assets. - [ ] Only publish referenced assets.
- [ ] Split `load_page` into frontmatter-parse + body-process phases so draft pages can skip the markdown pipeline entirely - [ ] Split `load_page` into frontmatter-parse + body-process phases so draft pages can skip the markdown pipeline entirely
- [ ] Use spall to find ways to reduce run time. - [ ] Use spall to find ways to reduce run time.
- [ ] Consider using `#soa` for Page lists.
## Memory Management ## Memory Management
@@ -28,14 +29,12 @@
- [ ] Clean up the default layouts - [ ] Clean up the default layouts
- [ ] Add `-production` flag - [ ] Add `-production` flag
- sets `-minify` - sets `-minify`
- [ ] Open Graph - [x] Open Graph
- [x] mustache data keys for opengraph, etc. - [x] mustache data keys for opengraph, etc.
- [ ] OpenGraph meta tags — verify all fields match production site - [x] OpenGraph meta tags — verify all fields match production site
- [ ] set opengraph tags / description automatically if unset. (Like hugo does) - [x] set opengraph tags / description automatically if unset. (Like hugo does)
- [ ] We can't use avatar.jpg as the default site image, that's unique to sbrow.github.io. We need to set that in the frontmatter of content/index.html. or possibly in the config - [x] We can't use avatar.jpg as the default site image.
- [ ] Add `og Open_Graph` to `Config_File` and if `Some`, use it as the base - [x] Add `og Open_Graph` to `Config_File`.
site og instead of `og_init()`?
- If we go this route, `og_init` might not be the best name.
- [ ] Author should be a struct adhering to https://schema.org/author - [ ] Author should be a struct adhering to https://schema.org/author
- [ ] Block attributes on code fences (`{ #ex-1 }`) — hello-world.md - [ ] Block attributes on code fences (`{ #ex-1 }`) — hello-world.md
- [ ] include-code shortcode (`{{< include-code ... >}}`) — i-ported-fd-to-odin - [ ] include-code shortcode (`{{< include-code ... >}}`) — i-ported-fd-to-odin
+4
View File
@@ -17,8 +17,10 @@ Page :: struct {
title: string, title: string,
description: string, description: string,
date: string, date: string,
lastmod: string,
menu: string, menu: string,
body_html: string, body_html: string,
og: Open_Graph,
draft: bool, draft: bool,
is_starred: bool, is_starred: bool,
_is_index: bool `private`, _is_index: bool `private`,
@@ -132,10 +134,12 @@ load_page :: proc(
page.title = fm.title page.title = fm.title
page.description = fm.description page.description = fm.description
page.date = fm.date page.date = fm.date
page.lastmod = fm.lastmod
page.draft = fm.draft page.draft = fm.draft
page.is_starred = fm.isStarred page.is_starred = fm.isStarred
page.menu = fm.menu page.menu = fm.menu
page.layout = fm.layout if fm.layout != "" else infer_layout(section, is_index) page.layout = fm.layout if fm.layout != "" else infer_layout(section, is_index)
page.og = fm.og
if strings.has_suffix(file_path, ".html") { if strings.has_suffix(file_path, ".html") {
page.body_html = strings.clone(body) page.body_html = strings.clone(body)
Generated
+3 -3
View File
@@ -51,11 +51,11 @@
}, },
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1783475452, "lastModified": 1784525419,
"narHash": "sha256-3S92fSuv32mjJz2Qb2F4405c21J55F4NIphz5K6hxco=", "narHash": "sha256-yocJ4I4Kd4as0UPMFs9P7laPvvA2x/Bj8EW46iW3VVM=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "05988b07fb05cbcb50be6bce197b4b5f75b5e61b", "rev": "a16c3fde2ffeab7f6326f50f460aaffde7ae066d",
"type": "github" "type": "github"
}, },
"original": { "original": {
+5 -5
View File
@@ -62,6 +62,8 @@
pkgs.tree-sitter-grammars.tree-sitter-html.src; pkgs.tree-sitter-grammars.tree-sitter-html.src;
css-grammar = mkGrammarStaticLib "tree-sitter-css" css-grammar = mkGrammarStaticLib "tree-sitter-css"
pkgs.tree-sitter-grammars.tree-sitter-css.src; pkgs.tree-sitter-grammars.tree-sitter-css.src;
odin = pkgs.unstable.odin;
ols = pkgs.unstable.ols;
in in
{ {
_module.args.pkgs = import nixpkgs { _module.args.pkgs = import nixpkgs {
@@ -108,7 +110,7 @@
src = ./.; src = ./.;
nativeBuildInputs = [ nativeBuildInputs = [
pkgs.odin odin
pkgs.pkg-config pkgs.pkg-config
]; ];
@@ -143,9 +145,7 @@
}; };
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = [odin ols ] ++ (with pkgs; [
odin
ols
cmark cmark
tree-sitter tree-sitter
@@ -153,7 +153,7 @@
unstable.helix unstable.helix
typescript-language-server typescript-language-server
vscode-langservers-extracted vscode-langservers-extracted
]; ]);
shellHook = '' shellHook = ''
export LIBRARY_PATH="${html-grammar}/lib:${css-grammar}/lib:$LIBRARY_PATH" export LIBRARY_PATH="${html-grammar}/lib:${css-grammar}/lib:$LIBRARY_PATH"
+25 -2
View File
@@ -8,11 +8,13 @@ Frontmatter :: struct {
title: string, title: string,
description: string, description: string,
date: string, date: string,
lastmod: string,
publishDate: string, publishDate: string,
draft: bool,
isStarred: bool,
menu: string, menu: string,
layout: string, layout: string,
og: Open_Graph,
draft: bool,
isStarred: bool,
} }
// parse_frontmatter splits raw file content into a Frontmatter struct and the // parse_frontmatter splits raw file content into a Frontmatter struct and the
@@ -49,11 +51,13 @@ parse_frontmatter :: proc(content: string) -> (fm: Frontmatter, body: string, ok
fm.title = json_get_string(obj, "title") fm.title = json_get_string(obj, "title")
fm.description = json_get_string(obj, "description") fm.description = json_get_string(obj, "description")
fm.date = json_get_string(obj, "date") fm.date = json_get_string(obj, "date")
fm.lastmod = json_get_string(obj, "lastmod")
fm.publishDate = json_get_string(obj, "publishDate") fm.publishDate = json_get_string(obj, "publishDate")
fm.draft = json_get_bool(obj, "draft") fm.draft = json_get_bool(obj, "draft")
fm.isStarred = json_get_bool(obj, "isStarred") fm.isStarred = json_get_bool(obj, "isStarred")
fm.menu = json_get_string(obj, "menu") fm.menu = json_get_string(obj, "menu")
fm.layout = json_get_string(obj, "layout") fm.layout = json_get_string(obj, "layout")
fm.og = json_get_open_graph(obj, "og")
ok = true ok = true
return return
@@ -77,3 +81,22 @@ json_get_bool :: proc(obj: json.Object, key: string) -> bool {
return false return false
} }
json_get_open_graph :: proc(obj: json.Object, key: string) -> Open_Graph {
og: Open_Graph
if v, ok := obj[key]; ok {
if inner, ok2 := v.(json.Object); ok2 {
og.title = json_get_string(inner, "title")
og.type = json_get_string(inner, "type")
og.image = json_get_string(inner, "image")
og.url = json_get_string(inner, "url")
og.description = json_get_string(inner, "description")
og.locale = json_get_string(inner, "locale")
og.site_name = json_get_string(inner, "site_name")
og.published_time = json_get_string(inner, "published_time")
og.modified_time = json_get_string(inner, "modified_time")
og.section = json_get_string(inner, "section")
}
}
return og
}
+137
View File
@@ -0,0 +1,137 @@
package main
import "core:strings"
strip_html_tags :: proc(s: string, allocator := context.allocator) -> string {
sb := strings.builder_make(allocator)
defer strings.builder_destroy(&sb)
in_tag := false
start := 0
for i in 0 ..< len(s) {
if s[i] == '<' && !in_tag {
if i > start {
strings.write_string(&sb, s[start:i])
}
in_tag = true
} else if s[i] == '>' && in_tag {
in_tag = false
start = i + 1
}
}
if start == 0 {
return s
}
if !in_tag && start < len(s) {
strings.write_string(&sb, s[start:])
}
return strings.to_string(sb)
}
unescape_html :: proc(s: string) -> string {
sb := strings.builder_make()
defer strings.builder_destroy(&sb)
start := 0
for i in 0 ..< len(s) {
if s[i] != '&' {
continue
}
semi := strings.index(s[i:], ";")
if semi < 0 {
break
}
entity := s[i : i + semi + 1]
replacement := ""
switch entity {
case "&amp;": replacement = "&"
case "&lt;": replacement = "<"
case "&gt;": replacement = ">"
case "&quot;": replacement = "\""
case "&#39;", "&apos;": replacement = "'"
case: continue
}
if i > start {
strings.write_string(&sb, s[start:i])
}
strings.write_string(&sb, replacement)
start = i + semi + 1
}
if start == 0 {
return s
}
if start < len(s) {
strings.write_string(&sb, s[start:])
}
return strings.to_string(sb)
}
// generate_summary produces a plain-text summary of an HTML fragment.
// Blocks (paragraphs, headings, list items) are extracted, their tags
// stripped, entities decoded, and accumulated word-by-word until the
// max_words threshold is crossed — at which point the rest of the
// current block is included before stopping. Mirrors Hugo's default
// summary behavior.
generate_summary :: proc(html: string, max_words: int = 70) -> string {
separated, _ := strings.replace_all(html, "</p>", "\n\n", context.temp_allocator)
separated, _ = strings.replace_all(separated, "</h1>", "\n\n")
separated, _ = strings.replace_all(separated, "</h2>", "\n\n")
separated, _ = strings.replace_all(separated, "</h3>", "\n\n")
separated,_ = strings.replace_all(separated, "</h4>", "\n\n")
separated, _ = strings.replace_all(separated, "</h5>", "\n\n")
separated, _ = strings.replace_all(separated, "</h6>", "\n\n")
separated, _ = strings.replace_all(separated, "</li>", "\n\n")
separated, _ = strings.replace_all(separated, "</blockquote>", "\n\n")
stripped := strip_html_tags(separated, context.temp_allocator)
plain := unescape_html(stripped)
blocks := strings.split(plain, "\n\n", allocator = context.temp_allocator)
defer delete(blocks)
sb := strings.builder_make(context.temp_allocator)
defer strings.builder_destroy(&sb)
word_count := 0
first := true
for raw_block in blocks {
block := strings.trim_space(raw_block)
if len(block) == 0 {
continue
}
// Collapse internal whitespace to single spaces.
block_sb := strings.builder_make(context.temp_allocator)
has_content := false
in_space := true
for c in block {
if c == ' ' || c == '\t' || c == '\n' || c == '\r' {
in_space = true
} else {
if in_space && has_content {
strings.write_byte(&block_sb, ' ')
}
strings.write_rune(&block_sb, c)
in_space = false
has_content = true
}
}
collapsed := strings.to_string(block_sb)
words := strings.split(collapsed, " ", allocator = context.temp_allocator)
if !first && word_count > 0 {
strings.write_byte(&sb, ' ')
}
strings.write_string(&sb, collapsed)
word_count += len(words)
first = false
delete(words)
if word_count >= max_words {
break
}
}
return strings.to_string(sb)
}
-12
View File
@@ -58,16 +58,4 @@ Errors (returned as `Data_Error` at render time):
- **Filter results** (e.g. the `[dynamic]Group` returned by `group_by`) are render-scoped allocations in `context.temp_allocator`. They die with the render call. No caller-side cleanup is needed. - **Filter results** (e.g. the `[dynamic]Group` returned by `group_by`) are render-scoped allocations in `context.temp_allocator`. They die with the render call. No caller-side cleanup is needed.
- The string data inside `Pipe_Filter` (op names, args) is borrowed from the template source — no cloning. - The string data inside `Pipe_Filter` (op names, args) is borrowed from the template source — no cloning.
### Future ops (not yet implemented)
The pipe framework is general; additional ops are straightforward to add to `apply_filter` in `pipes.odin`:
- `sort`, `sort_by <field>` — ordering
- `filter <field> <value>`, `where <field>` — selection
- `take <n>`, `take_last <n>`, `skip <n>` — slicing
- `reverse` — order flip
To add a new op:
1. Implement `apply_<op>(value: any, args: []string) -> (any, Render_Error)` in `pipes.odin`.
2. Add a `case` to `apply_filter`.
3. Add tests to `pipes_test.odin`.
+98 -21
View File
@@ -1,7 +1,5 @@
package main package main
import "core:fmt"
Open_Graph :: struct { Open_Graph :: struct {
title: string, title: string,
type: string, type: string,
@@ -10,31 +8,110 @@ Open_Graph :: struct {
description: string, description: string,
locale: string, locale: string,
site_name: string, site_name: string,
is_article: bool, is_article: Maybe(bool),
published_time: string, published_time: string,
modified_time: string, modified_time: string,
section: string, section: string,
} }
og_init :: proc(site: Site) -> Open_Graph { og_for_site :: proc(site: ^Site) -> Open_Graph {
return { og := site.og
site_name = site.title, if og.site_name == "" {
description = site.description, og.site_name = site.title
image = fmt.tprintf("%s/avatar.jpg", site.base_url), }
locale = "en_US", if og.description == "" {
og.description = site.description
}
if og.locale == "" {
og.locale = "en_US"
} }
}
og_for_page :: proc(site: Site, page: Page, base: Open_Graph) -> Open_Graph {
og := base
is_article := page.section != ""
og.url = page.url
og.title = strip_html_tags(page.title, context.temp_allocator)
og.type = "article" if is_article else "website"
og.is_article = is_article
og.section = page.section
og.published_time = page.date
return og return og
} }
og_for_page :: proc(site_og: Open_Graph, page: Page) -> Open_Graph {
og := site_og
is_article := !page._is_index
if page.url != "" {
og.url = page.url
}
if page.title != "" {
og.title = strip_html_tags(page.title, context.temp_allocator)
} else {
og.title = og.site_name
}
og.type = "article" if is_article else "website"
og.is_article = is_article
if page.section != "" {
og.section = page.section
}
if is_article {
if page.date != "" {
og.published_time = page.date
}
if page.lastmod != "" {
og.modified_time = page.lastmod
} else if page.date != "" {
og.modified_time = page.date
}
}
// Description priority for articles:
// page.og.description > page.description > body summary > inherited
// For non-articles (home, section index), inherited site.og.description
// is the fallback (matches production behavior — home inherits site
// description, section index is empty).
description_set := false
if page.og.description != "" {
og.description = page.og.description
description_set = true
}
if !description_set && page.description != "" {
og.description = page.description
description_set = true
}
if !description_set && is_article && page.body_html != "" {
og.description = generate_summary(page.body_html)
description_set = true
}
if !description_set {
if page._is_index && page.section == "" {
// Home: keep inherited site.og.description.
} else {
og.description = ""
}
}
if page.og.title != "" {
og.title = page.og.title
}
if page.og.type != "" {
og.type = page.og.type
}
if page.og.image != "" {
og.image = page.og.image
}
if page.og.url != "" {
og.url = page.og.url
}
if page.og.locale != "" {
og.locale = page.og.locale
}
if page.og.site_name != "" {
og.site_name = page.og.site_name
}
if page.og.published_time != "" {
og.published_time = page.og.published_time
}
if page.og.modified_time != "" {
og.modified_time = page.og.modified_time
}
if page.og.section != "" {
og.section = page.og.section
}
if page.og.is_article != nil {
og.is_article = page.og.is_article
}
return og
}
+8 -36
View File
@@ -57,32 +57,6 @@ build_page_context :: proc(page: Page) -> Page_Context {
} }
} }
strip_html_tags :: proc(s: string, allocator := context.allocator) -> string {
sb := strings.builder_make(allocator)
defer strings.builder_destroy(&sb)
in_tag := false
start := 0
for i in 0 ..< len(s) {
if s[i] == '<' && !in_tag {
if i > start {
strings.write_string(&sb, s[start:i])
}
in_tag = true
} else if s[i] == '>' && in_tag {
in_tag = false
start = i + 1
}
}
if start == 0 {
return s
}
if !in_tag && start < len(s) {
strings.write_string(&sb, s[start:])
}
return strings.to_string(sb)
}
load_template :: proc(vfs: ^VFS, virtual_path: string) -> mustache.Template { load_template :: proc(vfs: ^VFS, virtual_path: string) -> mustache.Template {
data, ok := vfs_get(vfs, virtual_path) data, ok := vfs_get(vfs, virtual_path)
if !ok { if !ok {
@@ -176,7 +150,7 @@ render_site :: proc(site: ^Site) {
now = now, now = now,
author = site.author, author = site.author,
params = site.params, params = site.params,
og = og_init(site^), og = site.og,
} }
// Find home page // Find home page
@@ -289,7 +263,7 @@ render_page_html :: proc(
data.body = page.body_html data.body = page.body_html
data.date_iso = page.date data.date_iso = page.date
data.date_display = format_date(page.date) data.date_display = format_date(page.date)
data.og = og_for_page(site^, page, base.og) data.og = og_for_page(site.og, page)
return render_template(content_tpl, data, partials) return render_template(content_tpl, data, partials)
} }
@@ -315,10 +289,7 @@ render_home_html :: proc(
data.title = site.title data.title = site.title
data.body = home.body_html data.body = home.body_html
data.pages = list_pages data.pages = list_pages
data.og.url = fmt.tprintf("%s/", site.base_url) data.og = og_for_page(site.og, home)
data.og.title = site.title
data.og.type = "website"
data.og.is_article = false
return render_template(content_tpl, data, partials) return render_template(content_tpl, data, partials)
} }
@@ -347,16 +318,17 @@ render_section :: proc(
data.body = section_index.body_html data.body = section_index.body_html
data.page_title = section_index.title data.page_title = section_index.title
data.title = fmt.tprintf("%s | %s", section_index.title, site.title) data.title = fmt.tprintf("%s | %s", section_index.title, site.title)
data.og.title = section_index.title data.og = og_for_page(site.og, section_index)
} else { } else {
data.page_title = capitalize(section) data.page_title = capitalize(section)
data.title = fmt.tprintf("%s | %s", capitalize(section), site.title) data.title = fmt.tprintf("%s | %s", capitalize(section), site.title)
data.og.title = capitalize(section) data.og.title = capitalize(section)
data.og.description = ""
data.og.url = fmt.tprintf("%s/%s/", site.base_url, section)
data.og.type = "website"
data.og.is_article = false
} }
data.posts = posts data.posts = posts
data.og.url = fmt.tprintf("%s/%s/", site.base_url, section)
data.og.type = "website"
data.og.is_article = false
return render_template(content_tpl, data, partials) return render_template(content_tpl, data, partials)
} }
+8 -1
View File
@@ -29,6 +29,7 @@ Site :: struct {
params: json.Object, params: json.Object,
features: bit_set[Feature], features: bit_set[Feature],
markdown_extensions: bit_set[md.Extension], markdown_extensions: bit_set[md.Extension],
og: Open_Graph,
} }
Feature :: enum { Feature :: enum {
@@ -51,6 +52,7 @@ Config_File :: struct {
markdown_extensions: json.Value, markdown_extensions: json.Value,
params: json.Value, params: json.Value,
modules: json.Value, modules: json.Value,
og: Open_Graph,
} }
// Configuration loaded from command line arguments. Gets folded in to Site // Configuration loaded from command line arguments. Gets folded in to Site
@@ -70,7 +72,7 @@ Flags :: struct {
} }
init_site :: proc(site: ^Site, args: []string) { init_site :: proc(site: ^Site, args: []string) {
mem.dynamic_arena_init(&site.arena, alignment = 64) mem.dynamic_arena_init(&site.arena)
alloc := site_allocator(site) alloc := site_allocator(site)
// Set defaults // Set defaults
@@ -107,6 +109,9 @@ init_site :: proc(site: ^Site, args: []string) {
site_apply_cli_flags(site, _flags) site_apply_cli_flags(site, _flags)
site.config_path = path site.config_path = path
// Build the resolved site-level OG now that every other field is set.
site.og = og_for_site(site)
} }
load_config_file :: proc( load_config_file :: proc(
@@ -159,6 +164,8 @@ site_apply_config :: proc(site: ^Site, config: Config_File, config_dir: string)
} }
} }
} }
site.og = config.og
} }
site_apply_path_defaults :: proc(site: ^Site, config_dir: string) { site_apply_path_defaults :: proc(site: ^Site, config_dir: string) {