Skip to content

Instantly share code, notes, and snippets.

@alaestor
Created February 2, 2025 17:00
Show Gist options
  • Save alaestor/d3d05377902a7be00a731a8b16559fb4 to your computer and use it in GitHub Desktop.
Save alaestor/d3d05377902a7be00a731a8b16559fb4 to your computer and use it in GitHub Desktop.
Obsidian daily-note navigation buttons
function mkBtnMeta(id, icon, cmd) {
return `\`\`\`\`meta-bind-button
label: ""
icon: ${icon}
hidden: true
class: ""
tooltip: ""
id: ${id}
style: primary
actions:
- type: command
command: ${cmd}
\`\`\`\`\n`;
}
function mkBtn(id) {
return `\`BUTTON[${id}]\``;
}
const prev = "dailynav-prev";
const today = "dailynav-today";
const next = "dailynav-next";
dv.paragraph(
mkBtnMeta(prev, "chevron-left", "daily-notes:goto-prev") +
mkBtnMeta(today, "calendar", "daily-notes") +
mkBtnMeta(next, "chevron-right", "daily-notes:goto-next") +
`${mkBtn(prev)} ${mkBtn(today)} ${mkBtn(next)}`)
@alaestor
Copy link
Author

alaestor commented Feb 2, 2025

This Dataview JS script generates and inserts markdown to create user-friendly Meta-Bind buttons that utilize Obsidian's built-in daily-notes commands. It gets loaded at the top of my daily notes with dv.view("path/to/daily.js") for maintainability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment