# `Brix.Gen`
[🔗](https://github.com/LoamStudios/brix/blob/main/lib/brix/gen.ex#L1)

Shared helpers for Brix generator mix tasks.

# `find_template`

Finds a template by name. Normalizes hyphens to underscores.
Returns `{:ok, template}` or `:error`.

# `latest_version`

Finds the latest version directory in a page dir, by timestamp.
Returns `{version_name, version_dir}` or `nil`.

# `next_position`

Scans a directory for `{NN}-*` files/dirs and returns the next position number.
Returns 1 if the directory is empty or doesn't exist.

# `normalize_slug`

Normalizes a slug: strips leading `/`, lowercases, validates characters,
then prepends `/`.

# `pad_position`

Zero-pads a number to 2 digits.

# `page_dir`

Resolves the page directory for a given slug.
Slug `/` maps to `index/`, others strip leading `/`.

# `parse_content_dir`

Parses `--content-dir` from args, defaulting to `priv/content`.
Returns `{content_dir, parsed_opts, remaining_args}`.

`extra_switches` are merged with the base `[content_dir: :string]`.

# `resolve_version`

Resolves which version to use: explicit `--version` option, or latest.
Returns `{version_name, version_dir}` or exits with error.

# `scaffold_fields`

Generates placeholder field values from a template definition.
Required strings get `"TODO"`, optional get `""`, booleans get `false`, etc.
Skips `:sections` type fields (those become `.children/` directories).

# `sections_fields`

Returns the field names in a template that have type `:sections`.

# `template_to_filename`

Converts a template name to a kebab-case filename segment.
`"reviews_section"` → `"reviews-section"`

# `templates_by_name`

Returns a map of template name → %SectionTemplate{}.

# `titleize`

Titleizes a slug segment: `"my-page"` → `"My Page"`.

# `to_yaml`

Generates YAML from an ordered list of `{key, value}` pairs.
Handles strings, numbers, booleans, nil, empty maps, and
one level of nested maps (for `fields:` blocks).

# `validate_and_report`

Runs `Brix.Validator.validate/1`, prints issues, returns `:ok` or `:error`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
