-
-
Save vkostyanetsky/6c70f00b817157f9b6e62ee89bade853 to your computer and use it in GitHub Desktop.
Day Switcher for Obsidian
This file contains hidden or 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
```dataviewjs | |
function noteLink(noteName) { | |
return `[[Days/${noteName}|${noteName}]]` | |
} | |
const day = 24 * 60 * 60 * 1000 | |
const thisNoteDate = new Date(dv.current().file.name) | |
const thisNoteName = moment(thisNoteDate).format("YYYY-MM-DD") | |
const prevNoteDate = thisNoteDate.valueOf() - day | |
const prevNoteName = moment(prevNoteDate).format("YYYY-MM-DD") | |
const prevNoteLink = noteLink(prevNoteName) | |
const nextNoteDate = thisNoteDate.valueOf() + day | |
const nextNoteName = moment(nextNoteDate).format("YYYY-MM-DD") | |
const nextNoteLink = noteLink(nextNoteName) | |
let titleString = thisNoteDate.toLocaleString("en-US", {weekday: 'long'}) | |
titleString = titleString.charAt(0).toUpperCase() + titleString.slice(1) | |
dv.paragraph(`> [!seealso] ${titleString} | |
> ${prevNoteLink} ← ${thisNoteName} → ${nextNoteLink}`) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment