It’s not easy to follow exactly what you have got. If you post code, please put t inside a pair of triple back ticks (```), and do consider sharing a link to the action itself.
The code sometimes is referencing draft
, which is the draft loaded when you ran the action, and sometimes is referencing d
, which is the draft that you are creating mid-action.
For the title specifically, I would choose Greg’s first suggestion of the title attribute an change this…
let title = draft.processTemplate("[[title]]");
d.addTag(title);
… to this …
d.addTag(d.title);
You also appear to be processing the template
variable, which is based on two template tags. t1_text
and a1_text
. Unless those tags contain Drafts template tags, do keep in mind that there is no need to process the template
variable to set d.content
. Given that the look to be a title and author, my guess is that they will not contain Drafts template tags.
I suspect that the code above could be amended to something like this:
let d = Draft.create();
d.content = `# ${draft.getTemplateTag(‘t1_text’)}
Author: ${draft.getTemplateTag(‘a1_text’)}
Started reading:
## Facts
`;
d.addTag(d.title);
d.update()
editor.load(d);
editor.activate();
Does this work for you?