Open peteruithoven opened 4 years ago
I like it. Contribution Welcome.
If you'd like to take it. This might the file and I guess you can get siteConfig
there.
Ah interesting! I noticed that sourceDir
and therefore the @source
alias revers to the src
folder so in my case I was able to refer to the image using:
![Forest](~@source/.vuepress/public/images/forest.jpg)
With my base
config set to /experiments/vuepress/
this is then translated to the following html:
<img src="/experiments/vuepress/assets/img/forest.90378e61.jpg" alt="Forest">
So I guess because this is a "compile time" thing the base
doesn't really matter that's handled automatically by webpack.
Now I'm not sure how to proceed. Files in this ./vuepress/public/
folder are included anyway, so having them also uploaded to /assets/img/
doesn't really make sense.
If I place the image in src/images/
I can use:
![Forest](~@source/images/forest.jpg)
This results in
<img src="/experiments/vuepress/assets/img/forest.90378e61.jpg" alt="Forest">
But then I'm not sure this is an big enough improvement over using relative paths to warrant the complexity of the ~@source/
path. For example from a markdown file in /src/blog/
I can also refer to the same image using:
![Forest](../images/forest.jpg)
This will result in the same html. I think the ~@source/
only makes sense if you expect to move the file a lot and/or you have a lot of folder.
It might be interesting to mention this existing @source
alias in the documention, for example here:
Feature request
What problem does this feature solve?
When using a different base it's not possible to use the regular image markdown syntax, for example:
Currently the workaround is using html and withBase
What does the proposed API look like?
Would it be possible to use a webpack alias to refer to the base url? For example:
But, this doesn't work out of the box. I tried this and got the following error
I used the following config to add the public alias.
Docs:
How should this be implemented in your opinion?
By including a default webpack alias?
Are you willing to work on this yourself?
Yes, but I'd need some tips.