Auto-sync .note files to markdown, with mirror/watch folders - #120
Draft
philips-clanker wants to merge 1 commit into
Draft
Auto-sync .note files to markdown, with mirror/watch folders#120philips-clanker wants to merge 1 commit into
philips-clanker wants to merge 1 commit into
Conversation
Adds an opt-in auto-sync: when a .note file is created or modified in
the vault (e.g. by a mobile sync tool), its markdown export is written
or updated automatically, optionally scoped to a watched folder and/or
mirrored into a separate folder instead of sitting alongside the .note
file.
Along the way, fixes writeMarkdownFile's path construction, which used
`${file.parent?.path}/${file.basename}.md` - for vault-root files
Obsidian returns "/" as the parent path, producing a "//name.md"
double-slash bug. The path is now derived from file.path directly.
Split out of #81 (by @Floper), ported onto the current settings.ts
declarative API and current main.ts VaultWriter shape.
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
Split out of #81 (by @Floper), rebased onto current
main. This is the auto-sync + mirror/watch-folder piece; it has no dependency on the other pieces of #81..notefile is created or modified in the vault (e.g. by a mobile sync tool), automatically write/update its markdown export.modifyevents are debounced (2s) since a sync can fire several in quick succession for one file.createandmodifyfor the same sync: falls back fromvault.createtovault.modifyif the file already exists by the time we write..mdfiles into a separate folder that mirrors the.notestructure, instead of alongside each.notefile.ensureFolderExistscreates missing intermediate folders.writeMarkdownFile's path construction used`${file.parent?.path}/${file.basename}.md`, which produces//name.mdfor vault-root files (Obsidian returns"/"as the root folder path). Now derived fromfile.pathdirectly.Ported onto the current
settings.tsdeclarative-settings API and the currentVaultWritershape (mainhas diverged substantially from #81's base).Test plan
npm run build(tsc + esbuild) - cleannpx eslint src/main.ts src/settings.ts- 0 errorsnpx vitest run- 22 passed.notefile, confirm.mdexport appears/updates; test watched-folder and mirror-folder settings together and independently