Action
→ Obsidian — OlivierPS
Send the draft into an Obsidian vault.
- The note’s name is either the heading or the creation date-time, depending on the drafts beginning with a header or not.
- A YAML header is added with the creation date and time of the draft.
- The tags are written at the end of the note, under a separator line.
- The vault name is an editable constant.
Steps
-
script
/* Send to Obsidian with Tags ========================== Built from Ulysses sheet w/ tags. Tags are appended to the note, after a seperator line. Modify vaultName with the vault you want the note in. Improvements by Olivier Spinnler ———————————————————————————————— * A YAML header is added with the creation date of the *Drafts* note. * If the first character of the note is a `#`, it means that the note’s first line is a header. Thus → The header is used as the *Obsidian* note filename * … otherwise (i.e. the note doesn’t start with a `#`) → the note’s creation date in ISO format is used as the filename. */ const vaultName = "Calepin"; const baseURL = "obsidian://new"; /* If the draft’s first caracter is a “#”, we’ll use the heading as the filename. Otherwise, the filename will be the ISO creation date. */ let fileName = draft.displayTitle; // in case the draft begins with a “#”, we’re done! if (draft.content[0] !== "#") { fileName = strftime( draft.createdAt, "%Y-%m-%d@%Hh%M-%S"); } let cb = CallbackURL.create(); cb.baseURL = baseURL; cb.addParameter( "vault", vaultName); cb.addParameter( "name", fileName); // // Adding Tags to the end of the draft, make sure there are no spaces in the Drafts tags // let tags = draft.tags; let ctags = ""; for (let i = 0; i < tags.length;i++) { let nstag = "#" + tags[ i].replaceAll( ' ', '_'); ctags += nstag; ctags += " "; } /* Let’s add YAML metadata with created date */ let YAMLmetadata = "---\nCreated:\t"; YAMLmetadata += strftime( draft.createdAt, "%d.%m.%Y %H:%M"); YAMLmetadata += "\n---\n"; draft.content = YAMLmetadata + draft.content; // // Add a separator and then add the tags // draft.append( "\n------------------------------------"); draft.append( ctags); cb.addParameter("content", draft.content); cb.waitForResponse = false; var success = cb.open();
Options
-
After Success Trash , Tags: sent2obsidian Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.