Prototype: optional YAML front matter on generated markdown (#57) - #182
Draft
philips-clanker wants to merge 1 commit into
Draft
Prototype: optional YAML front matter on generated markdown (#57)#182philips-clanker wants to merge 1 commit into
philips-clanker wants to merge 1 commit into
Conversation
Prototype for #57: a new "Add YAML front matter to Markdown files" setting (default off) prefixes generated notes with tags, a source link, device model, page count, and keywords, making imported notes filterable via Obsidian's property search, Dataview, and Bases.
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Prototype for #57 ("Adding YAML"): adds an opt-in setting, "Add YAML front matter to Markdown files" (off by default), that prefixes generated notes with a small, fixed set of front matter properties:
tags: [supernote]— lets a vault filter/query every Supernote-imported note (e.g.tag:#supernoteor a DataviewFROM #supernote).source— a link back to the original.note/.spdfile as a property (not just the existing body-text link), so it's usable in Obsidian's property search ([source]) and in Dataview/Bases link queries.device— the capturing device model (SupernoteX.header.APPLY_EQUIPMENT), omitted when the device didn't record one.pages— page count, useful for sorting/filtering long vs. short notes.keywords— the device's own "starred" keywords, deduplicated across all pages, omitted when there are none.Serialization is hand-rolled (
src/frontmatter.ts, no new dependency) usingJSON.stringifyfor double-quoted YAML scalars, which safely escapes colons/quotes in note titles or keywords without needing a YAML library.Kept intentionally small for a first pass — no template/Templater integration, no custom per-vault property mapping, no
created/modifieddates (the.noteformat doesn't carry a real creation timestamp;TFile.stat.ctimewould just be vault-import time, which felt more misleading than useful to include by default). Posted a comment on #57 with the fuller brainstorm of what else front matter could carry, for discussion before committing to a fixed schema.Test plan
npx vitest run— all existing tests plus newsrc/frontmatter.test.tspassnpx tsc --noEmit— cleannpm run lint— clean (no new warnings)npm run build— builds cleanly