I am trying to put a daily note into a canvas, and I found a solution? but the solution does not work on my end
I am not as technical or a programmer at all what so ever so please forgive me.
This appears when I put in the code into the canvas.
Evaluation Error: TypeError: Cannot read properties of undefined (reading ‘file’)
at eval (eval at (plugin:dataview), :2:58)
at eval (eval at (plugin:dataview), :8:42)
at DataviewInlineApi.eval (plugin:dataview:18869:16)
at evalInContext (plugin:dataview:18870:7)
at asyncEvalInContext (plugin:dataview:18877:16)
at DataviewJSRenderer.render (plugin:dataview:18906:19)
at DataviewJSRenderer.onload (plugin:dataview:18448:14)
at e.load (app://obsidian.md/app.js:1:1167250)
at DataviewApi.executeJs (plugin:dataview:19449:18)
at DataviewPlugin.dataviewjs (plugin:dataview:20357:18)
![[2024-07-21]]%%embed%%
```dataviewjs
// Get the current file
const file = app.vault.getAbstractFileByPath(dv.current().file.path)
// Get the text contents of the current file
let contents = await app.vault.read(file)
// Update any text on the line before %%embed%% to be an embedded link to today's note
contents = contents.replace(/^.*?%%embed%%$/m, '![[' + moment().format('YYYY-MM-DD') + ']]%%embed%%')
// Save the new contents back to the current file
await app.vault.modify(file, contents)
From the original post. I tried to use the same thing, this is modified for YYYY-MM-DD date format of daily notes.
Make a new note i.e ‘Dynamic Daily Note’ and paste this inside, make sure the lines are not joined together
Import that note into your canvas, you may need to close the note and the canvas, to get it to refresh but it should show an embedded link.
I have yet to find a way to modify the embedded daily page instead of just displaying it, but this works for me