How to insert a project before a specific project?

Thrilled to do so. I appreciate the Wiki, and your efforts with it!

function TaskPaperContext(editor, options) {
const d = new Date();
const dtd = d.getMonth() + 1 + "/" + (d.getDate() + 1) + " through " + (d.getMonth() + 1) + "/" + (d.getDate() + 7);
    let outline = editor.outline
    let project = outline.createItem('→ Habits Tracker → ' + dtd + ":")
    project.appendChildren([
        outline.createItem('- Drink 40oz of water → ○○○○○○○'),
        outline.createItem('- Walk thirty minutes → ○○○○'),
        outline.createItem('- Intermittent fasting → ○○○'),
        outline.createItem('- Brainstorm → ○○○'),
        outline.createItem('- Meditate → ○○○'),
        outline.createItem('- Read → ○○○'),
        outline.createItem('- Write → ○○○')
    ])
    let links = editor.outline.evaluateItemPath('project Links:')[0]
    links.parent.insertChildrenBefore(project, links)
    editor.moveSelectionToItems(project, 0, project, 0)
}

Application('TaskPaper').documents[0].evaluate({
  script: TaskPaperContext.toString()
});
2 Likes