question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'[]()' rendered as link in dv.pages() folder query, but string in #tag query

See original GitHub issue

Describe the bug I’ve been trying to remap fields to create a new list of markdown links (i.e. [file.alias](file.path)), and discovered that using identical queries with dv.pages() creates different results depending on whether you’re querying a folder or a tag.

To Reproduce

  1. Create two dataviewjs blocks like this: console.log(dv.pages("#project").map(k => '[' + k.file.name + '](' + k.file.path + ')')) console.log(dv.pages('"Folder"').map(k => '[' + k.file.name + '](' + k.file.path + ')'))
  2. If you check the output, you’ll see each creates an array with identically formatted items: "[name](path)"
  3. Now use dv.list() instead of logging to the console dv.list(dv.pages("#project").map(k => '[' + k.file.name + '](' + k.file.path + ')')) dv.list(dv.pages('"Folder"').map(k => '[' + k.file.name + '](' + k.file.path + ')'))
  4. You should see something like this: Screen Shot 2021-08-21 at 12 37 43 PM

In other words, a folder query actually renders the markdown, while a tag query simply displays the plaintext.

Expected behavior Instead, I’d expect each of these to be rendered the same, with working links to the notes. The source should have no effect on the way it’s rendered, no?

Desktop (please complete the following information):

  • OS: MacOS Big Sur
  • Obsidian Version [e.g. 0.12.13]
  • Dataview Version [e.g. 0.4.4]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
blacksmithgucommented, Aug 22, 2021

@nkoder I did some investigation and I think you are exactly correct. Obsidian does not like spaces in paths to markdown files, and will not render them as links unless you replace space with %20.

As another option for this, note there is a link method withDisplay which lets you set the render for the link. Try this:

dv.list(dv.pages("#thing").map(k => k.file.link.withDisplay(k.file.aliases[0] || k.file.name)));
0reactions
blacksmithgucommented, Aug 30, 2021

Good to hear you found a workaround and you’ve found Dataview useful! dv.func.link() is also a good alternative here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Codeblock Reference - Dataview - GitHub Pages
Query methods allow you to query the Dataview index for page metadata; to render this data, use the methods in the render section....
Read more >
DataviewJS query to render number of pages with given tag ...
Dear fellows, I tried a DataviewJS query to render the number of pages with a certain tag & a key value that is...
Read more >
Obsidian Dataview - GitHub
Provides a JavaScript API and pipeline-based query language for filtering, sorting, and extracting data from Markdown pages. See the Examples section below ...
Read more >
Razor Pages with Entity Framework Core in ASP.NET Core
Shows how to create a Razor Pages app using Entity Framework Core. ... async if they call EF Core methods that send queries...
Read more >
How to get started with Obsidian Dataview and DataviewJS
“Treat your Obsidian Vault as a database which you can query from” ... dv.taskList(dv.pages().file.tasks.where(t => t.completed));
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found