DataviewJS Insert Block links

Similar to this thread I’m looking for a way of inserting a block id that can reference from other notes. Currently I have certain notes that I refer to as “annotations” which are basically atomic quote notes.

An example notes looks something like this:

---
id: A-202301261028
quote: My walk... is a public one. My business is in the world; and I must mix in the assemblies of men, or quit the post which Providence seems to have assigned me"
sources:
  - { person: [[William Wilberforce]], place: [[📕 Spark]], location: test }
  - { place: [[📕 Leadership as an Identity]], location: Chapter 20 }
tags:
- servant-leadership
- faithfulness
---
\`\`\`dataviewjs 
dv.view("dv-views/annotations/v1")
\`\`\`

^d117db

This works great for the note itself, and even on my specific “book” or “person” notes I can easily list all related quotes like this:

dv.view("dv-views/book-annotations/v1")

Now the only remaining requirement/request I have is to insert a custom ^quote (see first image for reference). This way anytime I want to reference (typically with translucency) I can do something like ![[A-202301261028^quote]]

I’ve tried to so something like this in my index.js, but it did not create the same html markup as a proper block ID and ultimately it didn’t work to be recognized by my separate note.

dv.el("div", 
    dv.el("span", "^quote ", { cls: "cm-blockid", spellcheck:"false"}), 
    { cls: "cm-line"}
);

Would love any help I could get with this, curious if its possible and if not, how could I get it on the roadmap?

Sorry, I’m having trouble following exactly what you’re looking for here. Is this a Dataview feature or an Obsidian feature)

Maybe it would help to elaborate on how you imagine the following would happen:

So I think I got this to work, not sure what I was misunderstanding at the time but it actually works just as I hoped. So I have an annotation note with the following:

as part of my template, just below the dataview snippet I have a ^quote call that makes it possible for me to reference only the quote and not all of the additional notes within the file.

As you can see here this seems to work as expected so I’m happy.

2 Likes

@ryanjamurphy My apologies, what I described as working I realized is not what I was trying to do (this is what I get for going on a trip between posting and replying). As I described in my last replay, place a ^quote below my dataviewjs block works as expected, but what I wanted to accomplish was inserting that same ability within the view.js (between the quote the quote and the source detail as seen here.

Using the following code I was able to insert the text as expected but it doesn’t function as a callable section for transclution as expected.

dv.el("div", 
    dv.el("span", "^quote ", { cls: "cm-blockid", spellcheck:"false"}), 
    { cls: "cm-line"}
);

Instead I get the following error:

I have to ask again: What are you really trying to do? What’s your goal with this workflow?