Use URL in property to link text

What I’m trying to do

I have a property called center_url with an external link to a Discourse discussion topic. I want in the markdown to have linked text that includes the title of the note with the whole line linked.

Things I have tried

I’ve searched dataview docs, the dataview example vault, and help.

`= this.center_url`

This does display the URL.

[Discuss `= this.title` on the community center](`= this.center_url`)

Does not work. Tried getting AI help, but those recommendations didn’t fly either. Tried dataviewjs but kept getting errors.

Anyone have a simple-ish solution here?
Thanks ~

`$= “<a href='”+ dv.current().center_url + “’ />Discuss <b>”+ dv.current().title + “</b> here</a>”`

Ok. So this got what I wanted to appear in the document.

AND, I discovered that whatever dataview is generating doesn’t end up in exported by the Copy to HTML or the export as… plugins. The dataview code does.

Only export to PDF (built in function) seems to include the dataview content already rendered.


I am using this to be able to write/edit/generate markdown/html for publishing in various other places. Wasn’t expecting this gotcha. Hmmm.

Suggestions welcome!

I don’t how tech savy you are, but it could possibly be achieved using some trickery to persist the dataview result using a template. I’ve started tinkering about something similar for complete queries, but the gist of it is to mark the query using comments with a special syntax, and then when you run the template you replace another section with the new result of the query.

An example showing the gist of such an idea:

<!--=start "test=" + dv.current().center_url -->test=<!--=end-->

Now if you parsed this text line by line, and found a line with a comment starting with =start, you could expand the rest of that comment, and insert before the =end comment tag. Now the result would be persisted in the document, and the comment ignored (not shown in reading, but shown as comment in live preview).

Variation over this theme could be explored, where you then wouldn’t be depending on dataview to be run. You would however need to trigger the template with correct options before you export your stuff, so it’s the correct persisted variant displayed.

Hmmm. Thank you, and while I’ve got some tech skill, this feels awkward compared to how smooth I thought it was going to be. I may just take a different approach and let this simmer for a bit… Thanks!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.