fix(frontmatter): improve duplicate frontmatter key error handling
Summary
I fixed an issue with YAML frontmatter where duplicate keys caused a vague error that didn’t point to the real problem. I added a simple check that detects repeated keys and shows a clear message with the key name and line number which points to the file
Test plan
-ensured normal frontmatter files still parse correctly. -ran the formatter manually to confirm it now identifies the duplicated key. -verified that the error message displays the correct key and the line where it occurs.
Checklist
Please add a x inside each checkbox:
- [ x ] I have read the contribution guidelines.
Thanks for the feedback. ill update it now.
- i will remove the thrown error and replace it with a simple console.log warn without a stack trace.
- i will include the file path, key name, and line number in the warning message so it’s clear which entry is affected. -then limit the detection to the currently opened entry, so warnings don’t appear for every file in the collection.
- yes cms users shouldn’t see this so i will keep it in the console only for developers.
I’ll push the changes soon.
Alright now I get it. I'll now
-parse yaml structure properly -track full key paths -only warn when the same key appears in the same parent scope -ennsuring all existing tests pass before pushing the update
do tell if any changes are needed.