Tags Representing Tags

In Drafts, I use the tagging system to organize within the application. For instance since this draft started, I’ve used the writing:develop tag to place it in the Workspace for writing that I’m actively working on.

Drafts is where text starts, but pretty much all of it flows out of Drafts and is used elsewhere… and those documents need tags too!

I’ve been playing with tags that start with a hash1 like #draftsapp. In my custom actions they are passed on in the right format (usually YAML front after for a blog post or Zettel.) Here’s an example code snippet that built this blog post:

let tags = '';
if (draft.tags) {
  // draft.tags is readonly… this is a hack to make a copy.
  tags = '' + draft.tags
  tags = 
    tags
      .split(',')
      .filter(tag => tag.match(/#/))
      .map(tag => tag.replace("#", ""))
      .join(", ")
}

let template =
`---

title: ${draft.displayTitle}
date: ${strftime(date, "%F %R %Z")}
tags: ${tags}

---
${draft.processTemplate("[[body]]")}
`;

This would be easier if Drafts provided an Array of strings as drafts.tags, but it’s not too much work. (But Greg if you are reading… it’d be nice!)


  1. yes, I know it’s an octothorpe. 


Changelog
  • 2021-01-09 22:16:08 +0000

    split sentence

  • 2021-01-09 15:59:49 +0000

    update image

  • 2021-01-09 15:38:59 +0000

    post: tags representing tags