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

Local icons are not resolved correctly by cli #1919

Closed
ghost opened this issue Apr 22, 2024 · 5 comments · Fixed by #1924
Closed

Local icons are not resolved correctly by cli #1919

ghost opened this issue Apr 22, 2024 · 5 comments · Fixed by #1924

Comments

@ghost
Copy link

ghost commented Apr 22, 2024

When diagram is located in subfolder then relative path to icon location is not resolved correctly. Or at least not in the same way as it is by VSCode extension.

Repo with example: https://github.com/miroslav-matejovsky/d2-local-icons

@cyborg-ts cyborg-ts added this to D2 Apr 22, 2024
@alixander
Copy link
Collaborator

Right, this is because the images are just URL paths. It depends on where you open the SVG. For example, in your repo, GitHub renders it: https://github.com/miroslav-matejovsky/d2-local-icons/blob/trunk/cli-output-conf.svg

But in others that won't make network requests like, say, Adobe Illustrator, you need to bundle the images into base64 data. D2 playground doesn't do that right now: terrastruct/d2-playground#17

@ghost
Copy link
Author

ghost commented Apr 25, 2024

Thanks for explanation
If someone is using filewatcher to generate svg in vscode this (cd to folder with d2 definition) will help:

  "D2.previewTheme": "Cool classics",
  "filewatcher.commands": [
    {
      "match": "^.*\\.d2$",
      "isAsync": true,
      "cmd": "cd ${fileDirname} && d2 --layout tala --theme=4 ${file}
      "event": "onFileChange"
    }
  ],

@alixander
Copy link
Collaborator

alixander commented Apr 25, 2024

Wait I'm sorry this wasn't in regards to the Playground. I mistook this for a different issue.

When diagram is located in subfolder then relative path to icon location is not resolved correctly.

They both seems to have the correct icon in your repo. What's the issue? @miroslav-matejovsky

@ghost
Copy link
Author

ghost commented Apr 25, 2024

I've update README.md in my repo.

https://github.com/miroslav-matejovsky/d2-local-icons/blob/trunk/cli-output-conf.svg is incorrect, it should contain gear instead of eye.

@alixander
Copy link
Collaborator

Very much appreciate the detailed bug report. Fix will be part of next release, thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant