Q: Could we have custom frontmatter fields such as uuid?
mehdisadeghi opened this issue · 2 comments
Summary of issue
I would like to automate adding a uuid field to each post. Is this something that you would consider? In that case I can make a PR. I can think of having uid added by default or based on an option.
P.S. I use uuid as an identifier for generating unique feeds. As long as there is a unique ID inside each article, feed readers will know that it is still the same article, even if the content or title has changed.
Since using a uuid as an identifier on posts is something specific to your post workflow, I don't see it being a candidate for this package (i.e. I don't see this helping other users since it's a non-standard practice).
I would recommend building this yourself as a custom user plugin. Shouldn't take much code (I tossed this together and it seemed to work):
# /path/to/sublime/user/directory/InsertUuid.py
import uuid
import sublime
import sublime_plugin
class InsertUuidCommand(sublime_plugin.TextCommand):
def run(self, edit, **args):
view = self.view
uuid_str = str(uuid.uuid4())
for r in view.sel():
if r.empty():
view.insert(edit, r.a, uuid_str)
else:
view.replace(edit, r, uuid_str)
If you want to add this command to the command palette, just create a file like User.sublime-commands
and add this:
[
{
"caption": "Insert UUID",
"command": "insert_uuid"
}
]
@23maverick23 thanks for taking the time to write the script, I'll do it that way then.