Front matter schema validation
For certain use cases it may be useful to support schema validation (e.g. based on JSON schemas or similar) for front matter. This is useful both for checking the format as well as offering suggestions, e.g. with auto complete for “enum” style values.
Conceptually, this may look as follows:
---
$schema: <URL or page reference>
attribute1: value
attribute2: value
---
If `$schema` is specified, SB would use it to validate the remaining attributes, highlight validation errors etc.
This should be implementable as a plug, except for marking validation errors inline, this would require some extra syscalls and investigation.
cc @saturninoabril
We could use JSON schema: https://json-schema.org/
Or: https://github.com/hay-kot/flint
Something else to consider: in the past, I've continuously built "checker queries" that report to me with any files that are for example #person but don't have company: .... in their frontmatter. That way I was making sure I have consistent information. If sometimes that field is missing, my queries would get unreliable.
What I'm trying to say: We could also think about warning when there are certain things missing in frontmatter.
Your $schema-proposal already makes that viable.
Creation of files does need to be thought through though, because adding a schema by hand is a little cumbersome. Maybe suggesting already used $schema strings is a good idea? Maybe a custom plug could provide an empty state for notes which suggests different templates to choose from?
Adding a $schema thing within the page sounds a little messy. Can this be implemented similar to Object Decorators where we can target using path or tags etc.