Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add encodeURIComponent function to DSL #2526

Open
lily-mara opened this issue Feb 18, 2025 · 0 comments
Open

Add encodeURIComponent function to DSL #2526

lily-mara opened this issue Feb 18, 2025 · 0 comments
Labels
feature-request New feature or request.

Comments

@lily-mara
Copy link

lily-mara commented Feb 18, 2025

I use dataview for managing projects by having a list of "issues" open with the following query:

list from #issue and -#issue/solved where contains(related-to, this.file.link)

I'm able to create new "issues" by making a new note and applying the "Issue" template to the note, then linking it to the appropriate project, but I would like to create a button that does this automatically.

I've been able to accomplish this using an inline dataview query and it does function, but it's not ideal:

=elink("obsidian://new?content=---%0Atags%3A%0A%20%20-%20issue%0Arelated-to%3A%0A%20%20-%20%22%5B%5B"+ replace(replace(this.file.path, "/", "%2F"), " ", "%20") + "%5D%5D%22%0A---", "New")

There are a few papercuts, but the most significant is that the DSL lacks the encodeURIComponent JS function. This means that my URL needs to be percent-encoded out of the gate, making it a bit more annoying to write and edit, and it means that I need to manually do escaping of the / and characters in any file paths. If this function existed in the DSL, the "new note" URL could more straightforwardly be written. I'd hope to be able to write this

=elink("obsidian://new?content=" + encodeURIComponent("---\ntags:\n  - issue\nrelated-to:\n  - "+ this.file.link + "\n---"), "New")

This makes it much easier to see what's going into the link, and ensures that no special characters in the file name will be mis-escaped.

Describe alternatives you've considered

I could write the query using JS instead of the DSL, but I'm not familiar with the JS syntax and the documentation does not make it clear how to add an external hyperlink.

@lily-mara lily-mara added the feature-request New feature or request. label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request.
Projects
None yet
Development

No branches or pull requests

1 participant