Neat idea!
One possible approach: I have a QuickAdd (community plugin) macro that lets me press a keyboard shortcut and move the line I’m on to a specific section in my daily note. I have very similar one tied to a different keyboard shortcut that will open up the Quick Switcher for me to select a file and then move the line I’m on to the same pre-specified section in that note instead. (I use this for sending to other day’s notes. It would definitely break if I selected a file that didn’t have the section name that the macro sends it to.) This approach works for me because I like the idea that my files will not change unless I explicitly command them to (via the keyboard shortcut). If you’d prefer to type a tag to trigger the move I have no idea how to do that part.
I hope other folks can share their approaches and that between all of them you’ll find something that sounds good!
You can do this with the dataview plugin and inline metadata, mostly. If you can separate the sentences that need to be sent onto their own lines, you can do it like this in your notes:
reference:: Here is a sentence that should appear in another place.
differenttopic:: This sentence should appear in a different place.
reference:: This sentence should appear in the same place as the first, and it’s a little longer, but that’s okay.
And then in your reference note, you can put this dataview code:
Awesome, thanks for the tip! I’ll try this out now:
Just a few questions:
Do I just copy paste the dataview code into my reference note as is? or do I need to alter it in some way? ie. change the “original/notes/folder” to the folder path of my source note?
Would this code run automatically or would I need to trigger it somehow?
The code does just get put right into your note, but you’ll need to enclose the code in backticks, and there are two ways to do that:
One is in a block, where you start with 3 backticks and the word dataviewjs [```dataviewjs] and then the code on the next line (starting with “dv.list…” - take out the “$=”) and then three more backticks on the next line.
And the other way is inline, where you would copy my code exactly (keeping the $= in front) but you’ll need to enclose that in single backticks. So one backtick just before the $ and one backtick just after the last semicolon. (The forum renders them as code, so I can’t type them in!)
And make sure you’re using backticks, not single quote marks! (On my keyboard, the key is to the left of the 1/! key.)
And yes, you’ll need to change the path in the code to the folder where the notes that you want to pull the comments from are. So for me, I am pulling stuff out of my daily notes, which live in a folder called “Journal”. So that bit looks like [dv.pages(’“Journal”’)] for me. It will go down into subfolders - like I have mine organized into months - so you don’t need to specify every subfolder, just the top level one.
So the basic gist is that somewhere in one of my daily notes, there is text that looks like this:
coolthing:: My husband made the best lamb stew last night!
And then somewhere else (doesn’t have to be in the same folder), I have a note called Cool Things.md and all that is in that note is the code I pasted above (with ‘Journal’ in the path and ‘coolthing’ replacing ‘reference’). But when I look at that note in reading and/or live preview editing modes, I’ll see the list of coolthings that have been pulled from my daily notes. It is just there - you don’t have to do anything or run anything to see it.
This is exactly what I’m looking for EXCEPT if I have ‘coolthing::’ twice in the same note, I get both inline references appearing on the same line in the reference note, but separated by a comma. So I am try to get this:
link-to-file Here is a sentence that should appear in another place.
link-to-file This sentence should appear in the same place as the first, and it’s a little longer, but that’s okay.
but I am getting this:
link-to-file Here is a sentence that should appear in another place.,This sentence should appear in the same place as the first, and it’s a little longer, but that’s okay.
How did you separate the results into bullet points if you have the same inline reference twice from the same note?
Here we use a ternary operation, condition ? true-expr: false-expr, to split the two cases of a single reference in a file, and multiple references in the same file. If it’s an array, we map each of the values to our wanted output, and in the other case we make an array with the single value with want out of that file.
Hey - I’ve attempted to recreate the code you’ve used but get a response of which seems awfully weird. Has something changed in dataview ? (FWIW, I tried Holroy code and code from ellemef). Help!? Thanks. (BTW yes - I changed the designated folder).