Last active
March 6, 2024 18:47
-
-
Save sidedwards/ab67be678ff93081cd06bcd683e60106 to your computer and use it in GitHub Desktop.
Journal Template for Trilium Notes. https://github.com/zadam/trilium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api.addButtonToToolbar({ | |
title: 'New Journal Entry', | |
icon: 'book', | |
shortcut: 'alt+j', | |
action: async function() { | |
const todayDateStr = api.formatDateISO(new Date()); | |
const todayEntry = await api.runOnServer(async todayDateStr => { | |
return await api.getDateNote(todayDateStr); | |
}, [todayDateStr]); | |
const dateCreated = api.parseDate(todayEntry.dateCreated); | |
// newly created note isn't in the tree cache yet | |
if (new Date().getTime() - dateCreated.getTime() < 60 * 1000) { | |
await api.refreshTree(); | |
} | |
api.activateNote(todayEntry.noteId); | |
const request = async () => { | |
const response = await fetch('https://quotes.rest/qod?category=life'); | |
const json = await response.json(); | |
const journalEntry = await api.runOnServer(async (todayEntry, json) => { | |
const journalTemplate = ` | |
<blockquote> | |
<p>${json.contents.quotes[0].quote} - ${json.contents.quotes[0].author}</p> | |
</blockquote> | |
<p> </p> | |
<p> | |
<strong>1. Take a moment to reflect on yesterday.</strong> How was your nutrition? How was your physical activity? Did you achieve your daily goals? How did you feel? | |
</p> | |
<h2>Yesterday</h2> | |
<p> </p> | |
<p> | |
<strong>Action Item Follow-up</strong> | |
</p> | |
<ol> | |
<li> </li> | |
</ol> | |
<p> | |
<strong>2. Take a moment to plan for today.</strong> What does your schedule look like? Is there anything that doesn’t support today’s intention and if so, can you get it off your calendar? What would you like to achieve today? Which few small action items will help you achieve it? What are you grateful for? | |
</p> | |
<h2>Today</h2> | |
<p> </p> | |
<p> | |
<strong>Action Items</strong> | |
</p> | |
<ol> | |
<li> </li> | |
</ol> | |
<p> | |
<strong>Grateful For</strong> | |
</p> | |
<ol> | |
<li> </li> | |
</ol> | |
`; | |
return await api.createNote(todayEntry.noteId, 'Journal Entry', journalTemplate, {isProtected:true}); | |
}, [todayEntry, json]); | |
const journalDateCreated = api.parseDate(journalEntry.dateCreated); | |
// newly created note isn't in the tree cache yet | |
if (new Date().getTime() - journalDateCreated.getTime() < 60 * 1000) { | |
await api.refreshTree(); | |
} | |
api.activateNote(journalEntry.noteId); | |
}; | |
request(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script creates a "New Journal Entry" button that will create a new entry for that day when clicked. It also pulls in a quote of the day via the https://theysaidso.com/api/. Template preview below. I also added the isProtected flag so you'll have to enter a protected session to create or read entries.
Journal Entry
1. Take a moment to reflect on yesterday. How was your nutrition? How was your physical activity? Did you achieve your daily goals? How did you feel?
Yesterday
Action Item Follow-up
2. Take a moment to plan for today. What does your schedule look like? Is there anything that doesn’t support today’s intention and if so, can you get it off your calendar? What would you like to achieve today? Which few small action items will help you achieve it? What are you grateful for?
Today
Action Items
Grateful For