Action
Update Tags
Given a list of hashtags at the bottom of the draft update the assigned tags
Steps
-
script
let lastLine = draft.lines[draft.lines.length- 1]; if(lastLine.startsWith('#')) { let re = /#([\w]+)/g; let hashtags = [...lastLine.matchAll(re)]; let newtags = [] // because matchAll is returning both the full hashtag and the text just get the text hashtags.forEach(hashtag => { newtags.push(hashtag[1]); }); // add any tags that don't yet exist newtags.forEach(tag => { if(!draft.hasTag(tag)) { draft.addTag(tag); } }); // remove any tags that aren't in the list draft.tags.forEach(tag => { if(!newtags.includes(tag)) { draft.removeTag(tag); } }); draft.update(); }
Options
-
After Success Default Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.