obsidian-dataview icon indicating copy to clipboard operation
obsidian-dataview copied to clipboard

Transclusion of links

Open Gnopps opened this issue 4 years ago β€’ 15 comments

Thanks for developing this plugin!

Would it be possible to have the results published transcluded? So instead of the list produced being [[File_name]] it would be ![[File_name]].?

Gnopps avatar Mar 24 '21 22:03 Gnopps

It would probably be a different view (maybe a list view, or a 'transcude view?'), but yes, definitely possible.

blacksmithgu avatar Mar 25 '21 05:03 blacksmithgu

I'm very interested in this as it would replace a chunk of my workflow I've written some custom code for. It looks like the infrastructure is there based off what I see in this function: https://github.com/blacksmithgu/obsidian-dataview/blob/067ca4d5faffb83c6e5558df9ba3ddf6efca438a/src/data/value.ts#L75

I might take a stab at implementing this if I find the time.

erichalldev avatar Jul 13 '21 20:07 erichalldev

Hi,

This is exactly what I am looking for, as a replacement for 'Text Expander' (since the CM6 move broke it)

Has there been any activity on reaching this goal?

Thanks Mark

QuaCKeReD avatar Apr 08 '22 08:04 QuaCKeReD

Could you explain how this is related to text expander?

AB1908 avatar Apr 08 '22 08:04 AB1908

Could you explain how this is related to text expander?

I currently use text expander to transclude a list of files. DV can provide the list of links, but not the β€˜!’ to transclude them.

QuaCKeReD avatar Apr 08 '22 12:04 QuaCKeReD

Oh yeah, hmm. I imagine this is doable in DVJS though. Could also hook it up to templater to provide the list at runtime but it's quite hacky IMO.

AB1908 avatar Apr 08 '22 14:04 AB1908

If you could point me in right direction... πŸ˜›

Haven't figured out how to change the output formatting of DVJS 😟

QuaCKeReD avatar Apr 08 '22 15:04 QuaCKeReD

The general idea is that you could find the files you need with some DVJS and then output or append them to current file with Obsidian's API. For example:

let tfile = app.vault.getAbstractFileByPath("path/to/file");
let output = dv.pages("#test").file.name.map(t=>`![[${t}]]`).join("\n");
await app.vault.append(tfile, output);

AB1908 avatar Apr 08 '22 16:04 AB1908

Above kept erroring, so worked and got this

dv.list(
  dv.pages('"Diary" AND #test')
  .file.name
  .map(t=>`![[${t}]]`));

which does transclude the first file, but then rest just show as file names. Tried it using file.link and !${t}, with same result 😟

QuaCKeReD avatar Apr 08 '22 18:04 QuaCKeReD

This works!

dv.list(
  dv.pages('"Diary" AND #test')
  .forEach(p => dv.paragraph(dv.fileLink(p.file.name, true)))
);

QuaCKeReD avatar Apr 08 '22 22:04 QuaCKeReD

I've created a slightly different workaround using dataviewjs. See the last line in the code below.

let meetings = dv.current().file.inlinks
meetings = meetings.sort(k => dv.page(k).date, 'desc')
for (let meeting of meetings){
if (dv.page(meeting).file.tags.indexOf("#meeting")>-1){
dv.el("p", "![[" + dv.page(meeting).file.name + "]]");}
}

Gnopps avatar Apr 20 '22 13:04 Gnopps

Embed links seem to situationally work, and I've had better luck with them in DataviewJS than in Dataview for whatever reason.

blacksmithgu avatar Apr 21 '22 02:04 blacksmithgu

Hello, this still seems to be completely hit-or-miss for me after trying all the above methods (and playing around with dv.sectionLink and dv.fileLink with embed=true). I don't know if it's because of the live editor, but the embeds just seem to show the file name in plain text (not even as a link)

autolyticus avatar Aug 17 '22 13:08 autolyticus

What's your use case?

AB1908 avatar Aug 17 '22 14:08 AB1908

Nothing has really changed Obsidian-side w.r.t. being able to do embeds; there isn't much I can do in Dataview aside from manually trying to re-implement some common use cases like image embedding (via embed(link(...))).

blacksmithgu avatar Aug 18 '22 07:08 blacksmithgu

I found a good example of this over in SRS. Happy to help anyone walk through implementing that but I expect it won't work with live preview.

AB1908 avatar Oct 18 '22 22:10 AB1908

Hi, Yes, please, would love to see how this can be done.

PS: No idea what SRS is? πŸ˜›

QuaCKeReD avatar Oct 19 '22 07:10 QuaCKeReD

My use case is this:

  1. I create a topical kanban file, and add metadata to the yaml, like 'ΓΈ: work futures' to represent a project name and 'ΓΈΓΈ: meritocracy' to demote a subproject. These attributes are inherited by all tasks in the kanban. So far so good.
  2. The kanban tasks -- generally -- created in place as tranclusions, like ![[2022-09-17 pamela paul - when diversity isnt the right kind of diversity#^d88bdc]], which resolves in the kanban and markdown views.
  3. If I create a dataview query to find all tasks with those project and subproject attributes it 'works' -- the kanban tasks are all listed -- but the transclusions are not resolved:

2022-11-02 meritocracy dataview

I can click through on a task which takes me to the kanban task. Fine. And it is resolved there. But what might be best would be a dataview directive to same 'please resolve transclusions in the results'.

stoweboyd avatar Nov 02 '22 15:11 stoweboyd

I've seen a transclusion implementation here: https://github.com/st3v3nmw/obsidian-spaced-repetition/blob/80af505c082495e1956ca5aad11ddbe90c495af3/src/flashcard-modal.tsx#L418

I guess I can just steal this embedding magic wholesale inside the Dataview renderMarkdown function.

blacksmithgu avatar Nov 02 '22 23:11 blacksmithgu

I really wish Obsidian included a cleaner way of rendering embeds but this works for now. It took me quite a while to understand what was happening there haha.

AB1908 avatar Nov 03 '22 11:11 AB1908

ooo, is it ready for testing?

QuaCKeReD avatar Nov 03 '22 11:11 QuaCKeReD

No, not yet. Keep an eye on the releases for updates.

AB1908 avatar Nov 03 '22 11:11 AB1908