
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!)
-
yes, I know it's an octothorpe. ↩
Changelog
-
2022-06-08 11:31:29 -0500Rename articles
-
2021-01-09 16:16:08 -0600split sentence
-
2021-01-09 09:59:49 -0600update image
-
2021-01-09 09:38:59 -0600post: tags representing tags