Skip to content

feat(frontmatter): support nested keys via dot-notation#64

Merged
jackchuka merged 1 commit into
mainfrom
feat/nested-frontmatter-keys
May 6, 2026
Merged

feat(frontmatter): support nested keys via dot-notation#64
jackchuka merged 1 commit into
mainfrom
feat/nested-frontmatter-keys

Conversation

@jackchuka
Copy link
Copy Markdown
Owner

Summary

Resolves #59. Adds support for validating nested YAML frontmatter keys using dot-notation field names.

  • New object field type for asserting a parent is a map.
  • name: "metadata.author" traverses nested maps; works with both map[string]any and map[any]any (yaml.v3 may emit either for nested maps).
  • Backslash-escape (weird\.key) supports literal dots in segment names.
  • Generator emits properly indented nested YAML when multiple paths share a parent.

Example

frontmatter:
  fields:
    - { name: "title" }
    - { name: "metadata", type: object }
    - { name: "metadata.author" }
    - { name: "metadata.version" }
    - { name: "metadata.homepage", optional: true, format: url }

Validates documents like:

---
title: My Document
metadata:
  author: example-org
  version: "1.0"
---

Test plan

  • go test ./... — all green
  • go run ./cmd/mdschema check on a valid doc → no violations
  • Same on a doc missing metadata.author → reports Required frontmatter field 'metadata.author' is missing
  • go run ./cmd/mdschema generate produces nested YAML with proper indentation
  • schema.json regenerated and committed

Resolves #59. Field names can now use dot-notation paths
(e.g., `metadata.author`) to validate nested YAML frontmatter keys.
Adds `object` field type for asserting a parent is a map. Generator
emits properly indented nested YAML for grouped paths.
@jackchuka jackchuka marked this pull request as ready for review May 6, 2026 16:44
@jackchuka jackchuka merged commit e638c1e into main May 6, 2026
1 check passed
@jackchuka jackchuka deleted the feat/nested-frontmatter-keys branch May 6, 2026 16:44
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request May 8, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [jackchuka/mdschema](https://github.com/jackchuka/mdschema) | minor | `v0.12.9` → `v0.13.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>jackchuka/mdschema (jackchuka/mdschema)</summary>

### [`v0.13.0`](https://github.com/jackchuka/mdschema/releases/tag/v0.13.0)

[Compare Source](jackchuka/mdschema@v0.12.10...v0.13.0)

#### What's Changed

- feat(frontmatter): support nested keys via dot-notation by [@&#8203;jackchuka](https://github.com/jackchuka) in [#&#8203;64](jackchuka/mdschema#64)

**Full Changelog**: <jackchuka/mdschema@v0.12.10...v0.13.0>

### [`v0.12.10`](https://github.com/jackchuka/mdschema/releases/tag/v0.12.10)

[Compare Source](jackchuka/mdschema@v0.12.9...v0.12.10)

#### What's Changed

- ci(deps): bump goreleaser/goreleaser-action from 7.1.0 to 7.2.1 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;62](jackchuka/mdschema#62)
- deps(deps): bump github.com/invopop/jsonschema from 0.13.0 to 0.14.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;63](jackchuka/mdschema#63)

**Full Changelog**: <jackchuka/mdschema@v0.12.9...v0.12.10>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xNjguNSIsInVwZGF0ZWRJblZlciI6IjQzLjE2OC41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6bWlub3IiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for nested frontmatter keys

1 participant