Skip to content

feat(properties): support nested YAML frontmatter via dot-notation keys#1157

Merged
perber merged 2 commits into
mainfrom
feat/nested-frontmatter-properties
Jun 15, 2026
Merged

feat(properties): support nested YAML frontmatter via dot-notation keys#1157
perber merged 2 commits into
mainfrom
feat/nested-frontmatter-properties

Conversation

@perber

@perber perber commented Jun 12, 2026

Copy link
Copy Markdown
Owner

When a property key contains dots (e.g. "a.b"), the editor now stores it as proper nested YAML (a:\n b: value) instead of a flat literal dot-key. Sibling dot-keys sharing a parent are grouped under one YAML block.

The backend flattens nested ExtraFields maps with dot-joined keys so the properties index (a.b = value) and the page API response both reflect the nested structure. Guards added: depth limit (20) in extractFlatEntry, leafwiki_ prefix filter for child segments, and conflict detection in the field tree (scalar vs. mapping at the same path falls back to flat output).

When a property key contains dots (e.g. "a.b"), the editor now stores it
as proper nested YAML (a:\n  b: value) instead of a flat literal dot-key.
Sibling dot-keys sharing a parent are grouped under one YAML block.

The backend flattens nested ExtraFields maps with dot-joined keys so the
properties index (a.b = value) and the page API response both reflect the
nested structure. Guards added: depth limit (20) in extractFlatEntry,
leafwiki_ prefix filter for child segments, and conflict detection in the
field tree (scalar vs. mapping at the same path falls back to flat output).
Copilot AI review requested due to automatic review settings June 12, 2026 12:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds end-to-end support for nested YAML frontmatter properties by treating dot-notation keys as structured YAML in the editor, while flattening nested YAML maps back into dot-joined keys on the backend for indexing and API responses.

Changes:

  • UI: Parse nested YAML maps into dot-notation keys and serialize dot-notation keys back into nested YAML blocks (with sibling grouping and conflict fallback).
  • Backend: Flatten nested YAML maps into dot-notation keys when extracting page metadata and indexing properties, with added recursion-depth and reserved-prefix guards for indexing.
  • Tests: Add Vitest coverage for editor frontmatter round-trips and Go tests for nested-map property extraction.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
ui/leafwiki-ui/src/features/editor/frontmatter.ts Adds nested-map parsing and a field-tree serializer to emit nested YAML for dot-notation keys.
ui/leafwiki-ui/src/features/editor/frontmatter.test.ts Adds Vitest coverage for nested map parsing/building and round-trip behavior.
internal/wiki/pages/routes.go Updates page metadata extraction to flatten nested YAML maps into dot-notation properties for API responses.
internal/properties/properties_service.go Flattens nested YAML maps into dot-notation keys for the properties index with depth and reserved-prefix protections.
internal/properties/properties_service_test.go Adds tests validating nested map flattening, reserved child filtering, and depth limiting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ui/leafwiki-ui/src/features/editor/frontmatter.ts
Comment thread internal/wiki/pages/routes.go
Comment thread internal/properties/properties_service_test.go
Comment thread ui/leafwiki-ui/src/features/editor/frontmatter.test.ts Outdated
Comment thread ui/leafwiki-ui/src/features/editor/frontmatter.ts
- addToFieldTree: return false when an identical-path leaf already exists,
  preventing silent overwrites when two keys collapse to the same path
  after split('.').filter(Boolean)
- flatFallbacks: serialize list-type conflicted fields correctly instead
  of emitting them as bare scalars
- flattenMetadataEntry (routes.go): add depth limit (20) and skip child
  segments starting with leafwiki_ — mirrors the guards already present
  in extractFlatEntryDepth
- Rename misleading test case that described a list block as
  "unsupported nested content"
@perber
perber merged commit 08d964e into main Jun 15, 2026
9 checks passed
@perber
perber deleted the feat/nested-frontmatter-properties branch June 15, 2026 17:54
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.

2 participants