Posting to the web from Drafts
Sat Feb 11 2023Some notes on a mechanism for posting from Drafts with as little friction as possible.
- Write the text in Drafts
- Xocoyotl action
- formats draft as a post with front matter
- stores metadata used for updates & deletion
- pushes post to repo
- Pushing to GitHub triggers a deploy on Netlify
The Xocoyotl Action
the genesis of this action came from Blogging from Drafts | roub dot net
- Assembles front matter for the draft.
- Most of the data can be inferred from the draft itself:
- title (the first line of the draft)
- date (the current date)
- draftDate (date draft created)
--- title: <the H1 from the draft> date: 2023-02-10T20:02:51.521Z draftDate: 2023-02-10T02:33:55.380Z draft: drafts://open?uuid=B79AE5C3-E1A5-4831-B4C3-AAE06AE73CF5 github: https://github.com/tepiton/tlilli/blob/main/src/posts/b79ae5c3-e1a5-4831-b4c3-aae06ae73cf5.md newlines: false ---
- Data that can’t be derived from the draft is stored in
Drafts/Library/Scripts/t-<credentialName>
, keyed on the UUID of the draft- the repo name
- the path for the file
- whether to preserve newlines
"B79AE5C3-E1A5-4831-B4C3-AAE06AE73CF5" : { "newlines" : false, "repoPath" : "src/posts", "repo" : "tlilli" }
Credentials
- GitHub credentials are stored in a Drafts Credentials object.
- The credentials object stores the GitHub user name (or project name) and a corresponding personal access token.
- The name of the credential is used in the name of the external storage.